From bc197eb3ca3282a2ee69ec52dc6aad7a26d3013f Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Sat, 20 Dec 2025 12:57:47 +0800 Subject: [PATCH] refactor: massive refactor using flake-parts; use typos-cli and keep-sorted --- config/hosts/imxyy-nix-server/samba.nix | 2 +- flake.lock | 54 ++-- flake.nix | 298 +++++------------- lib/default.nix | 112 +------ lib/my.nix | 102 ++++++ lib/stdlib-extended.nix | 14 - modules/cli/misc.nix | 23 +- .../cli/monitor/btop/config/themes/nord.theme | 2 +- modules/cli/shell/fish.nix | 10 + modules/coding/editor/neovim/default.nix | 2 + .../editor/neovim/nvim/lua/core/options.lua | 10 +- .../neovim/nvim/lua/plugins/lsp/lspconfig.lua | 22 +- modules/i18n/fcitx5.nix | 2 +- modules/nix.nix | 3 +- modules/virt/types/input.nix | 2 +- modules/virt/types/spice.nix | 4 +- nixos.nix | 89 ++++++ overlays/default.nix | 84 ++--- pkgs/default.nix | 52 +++ treefmt.nix | 18 +- typos.toml | 16 + 21 files changed, 466 insertions(+), 455 deletions(-) create mode 100644 lib/my.nix delete mode 100644 lib/stdlib-extended.nix create mode 100644 nixos.nix create mode 100644 pkgs/default.nix create mode 100644 typos.toml diff --git a/config/hosts/imxyy-nix-server/samba.nix b/config/hosts/imxyy-nix-server/samba.nix index b2b1903..734c8d1 100644 --- a/config/hosts/imxyy-nix-server/samba.nix +++ b/config/hosts/imxyy-nix-server/samba.nix @@ -9,7 +9,7 @@ }; share = { path = "/mnt/nas/share"; - browseable = "yes"; + browsable = "yes"; "read only" = "no"; "guest ok" = "no"; "create mask" = "0664"; diff --git a/flake.lock b/flake.lock index 2a35f19..b37a2df 100644 --- a/flake.lock +++ b/flake.lock @@ -292,6 +292,26 @@ } }, "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1765835352, + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "go-musicfox", @@ -314,7 +334,7 @@ "type": "github" } }, - "flake-parts_3": { + "flake-parts_4": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, @@ -331,7 +351,7 @@ "type": "indirect" } }, - "flake-parts_4": { + "flake-parts_5": { "inputs": { "nixpkgs-lib": [ "stylix", @@ -473,7 +493,7 @@ "go-musicfox": { "inputs": { "devenv": "devenv", - "flake-parts": "flake-parts_3", + "flake-parts": "flake-parts_4", "flake-root": "flake-root", "mission-control": "mission-control", "mk-shell-bin": "mk-shell-bin", @@ -483,11 +503,11 @@ ] }, "locked": { - "lastModified": 1762961141, - "narHash": "sha256-q6B/qUbz2JvCLg3ZQKf24xsIICJz5Lh77Ki+fInfllU=", + "lastModified": 1766200280, + "narHash": "sha256-FGYAy+d0lJrsjvlnJi79jYBXm8NP1BLiYmYXze/3pRA=", "owner": "imxyy1soope1", "repo": "go-musicfox", - "rev": "266ae5f6a791e16a7afdc3d08b6294ceff0ec4d8", + "rev": "d7ac9fe76572eeef9fb4c8113d52243430497790", "type": "github" }, "original": { @@ -713,7 +733,7 @@ "go-musicfox", "devenv" ], - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "libgit2": "libgit2", "nixpkgs": "nixpkgs_2", "nixpkgs-23-11": [ @@ -900,22 +920,6 @@ "type": "github" } }, - "nixpkgs-working": { - "locked": { - "lastModified": 1762844143, - "narHash": "sha256-SlybxLZ1/e4T2lb1czEtWVzDCVSTvk9WLwGhmxFmBxI=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9da7f1cf7f8a6e2a7cb3001b048546c92a8258b4", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9da7f1cf7f8a6e2a7cb3001b048546c92a8258b4", - "type": "github" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1717432640, @@ -1049,6 +1053,7 @@ "catppuccin": "catppuccin", "darkly": "darkly", "fenix": "fenix", + "flake-parts": "flake-parts_2", "go-musicfox": "go-musicfox", "haumea": "haumea", "home-manager": "home-manager", @@ -1063,7 +1068,6 @@ "nixpkgs-master": "nixpkgs-master", "nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-unstable": "nixpkgs-unstable", - "nixpkgs-working": "nixpkgs-working", "noctalia": "noctalia", "plant": "plant", "sops-nix": "sops-nix", @@ -1117,7 +1121,7 @@ "base16-helix": "base16-helix", "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", - "flake-parts": "flake-parts_4", + "flake-parts": "flake-parts_5", "gnome-shell": "gnome-shell", "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index 3ad5518..50310d4 100644 --- a/flake.nix +++ b/flake.nix @@ -6,253 +6,115 @@ nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:nixos/nixpkgs/release-25.11"; nixpkgs-master.url = "github:nixos/nixpkgs/master"; - nixpkgs-working.url = "github:nixos/nixpkgs/9da7f1cf7f8a6e2a7cb3001b048546c92a8258b4"; # nixpkgs.follows = "nixpkgs-stable"; nixpkgs.follows = "nixpkgs-unstable"; # nixpkgs.follows = "nixpkgs-master"; - # TODO: sops-nix: remove pr patch once merged - # https://github.com/Mic92/sops-nix/pull/779 - sops-nix = { - url = "github:Mic92/sops-nix/pull/779/merge"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # Home manager home-manager = { url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - # Impermanence - impermanence.url = "github:nix-community/impermanence"; - - # Niri - niri.url = "github:sodiboo/niri-flake"; - - darkly = { - url = "github:Bali10050/Darkly"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - stylix = { - url = "github:danth/stylix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - # go-musicfox - go-musicfox = { - url = "github:imxyy1soope1/go-musicfox"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # NixOS-WSL nixos-wsl = { url = "github:nix-community/NixOS-WSL"; inputs.nixpkgs.follows = "nixpkgs"; }; - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; + # Flake organization tools + # keep-sorted start block=yes + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; }; - - zen.url = "github:0xc000022070/zen-browser-flake"; - zen.inputs.nixpkgs.follows = "nixpkgs"; - - noctalia = { - url = "github:noctalia-dev/noctalia-shell/v3.7.1"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - angrr = { - url = "github:linyinfeng/angrr"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - plant = { - url = "git+ssh://git@git.imxyy.top:2222/imxyy1soope1/HF-plant.git?rev=08dc0b3889797eb3618c7475c3c367ec0e5fdf40"; - flake = false; - }; - - catppuccin = { - url = "github:catppuccin/nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - infuse = { - url = "git+https://codeberg.org/amjoseph/infuse.nix"; - flake = false; - }; - haumea = { url = "github:nix-community/haumea/v0.2.2"; inputs.nixpkgs.follows = "nixpkgs"; }; + infuse = { + url = "git+https://codeberg.org/amjoseph/infuse.nix"; + flake = false; + }; + # keep-sorted end + # Useful modules + # keep-sorted start block=yes + catppuccin = { + url = "github:catppuccin/nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + impermanence.url = "github:nix-community/impermanence"; + # TODO: sops-nix: remove pr patch once merged + # https://github.com/Mic92/sops-nix/pull/779 + sops-nix = { + url = "github:Mic92/sops-nix/pull/779/merge"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + stylix = { + url = "github:danth/stylix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # keep-sorted end + + # Useful software + # keep-sorted start block=yes + angrr = { + url = "github:linyinfeng/angrr"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + darkly = { + url = "github:Bali10050/Darkly"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + go-musicfox = { + url = "github:imxyy1soope1/go-musicfox"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + niri.url = "github:sodiboo/niri-flake"; + noctalia = { + url = "github:noctalia-dev/noctalia-shell/v3.7.1"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + zen.inputs.nixpkgs.follows = "nixpkgs"; + zen.url = "github:0xc000022070/zen-browser-flake"; + # keep-sorted end + + # Misc treefmt.url = "github:numtide/treefmt-nix"; - + plant = { + url = "git+ssh://git@git.imxyy.top:2222/imxyy1soope1/HF-plant.git?rev=08dc0b3889797eb3618c7475c3c367ec0e5fdf40"; + flake = false; + }; my-templates.url = "git+https://git.imxyy.top/imxyy1soope1/flake-templates"; }; outputs = { - self, - nixpkgs, + flake-parts, ... }@inputs: - let - inherit (self) outputs; - vars = import ./vars.nix; - forAllSystems = lib.genAttrs lib.systems.flakeExposed; - forAllHosts = - mkSystem: - lib.mergeAttrsList ( - builtins.map (hostname: { - ${hostname} = mkSystem hostname; - }) (builtins.attrNames (builtins.readDir ./config/hosts)) - ); - - lib = (import ./lib/stdlib-extended.nix nixpkgs.lib).extend ( - final: prev: { - inherit (inputs.home-manager.lib) hm; - inherit infuse; - haumea = inputs.haumea.lib; - } - ); - infuse = (import inputs.infuse { inherit (nixpkgs) lib; }).v1.infuse; - in - { - packages = forAllSystems ( - system: - lib.haumea.load { - src = ./pkgs; - loader = [ - { - matches = str: builtins.match ".*\\.nix" str != null; - loader = _: path: nixpkgs.legacyPackages.${system}.callPackage path { }; - } - ]; - transformer = lib.haumea.transformers.liftDefault; - } - ); - - formatter = forAllSystems ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - treefmtEval = inputs.treefmt.lib.evalModule pkgs ./treefmt.nix; - in - treefmtEval.config.build.wrapper - ); - check = forAllSystems ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - treefmtEval = inputs.treefmt.lib.evalModule pkgs ./treefmt.nix; - in - { - formatting = treefmtEval.config.build.check self; - } - ); - - overlays = import ./overlays { - inherit inputs lib; + flake-parts.lib.mkFlake + { + inherit inputs; + specialArgs.lib = import ./lib { + inherit (inputs.nixpkgs) lib; + inherit inputs; + }; + } + { + systems = [ + "x86_64-linux" + ]; + imports = [ + ./nixos.nix + ./treefmt.nix + ./pkgs + ./overlays + ]; }; - - nixosConfigurations = forAllHosts ( - hostname: - let - overlays = builtins.attrValues self.overlays ++ [ - inputs.go-musicfox.overlays.default - inputs.niri.overlays.niri - inputs.fenix.overlays.default - inputs.angrr.overlays.default - (final: prev: { - darkly-qt5 = inputs.darkly.packages.${final.stdenv.hostPlatform.system}.darkly-qt5; - darkly-qt6 = inputs.darkly.packages.${final.stdenv.hostPlatform.system}.darkly-qt6; - - noctalia-shell = inputs.noctalia.packages.${final.stdenv.hostPlatform.system}.default; - }) - (final: prev: { - inherit lib; - }) - ]; - home = { - home-manager = { - sharedModules = [ - inputs.sops-nix.homeManagerModules.sops - inputs.impermanence.nixosModules.home-manager.impermanence - inputs.stylix.homeModules.stylix - inputs.noctalia.homeModules.default - inputs.zen.homeModules.beta - # workaround for annoying stylix - ( - { lib, ... }: - { - nixpkgs.overlays = lib.mkForce null; - } - ) - ]; - useGlobalPkgs = true; - }; - }; - pkgsConf.nixpkgs = { - inherit overlays; - config.allowUnfree = true; - flake.setNixPath = false; - }; - in - lib.nixosSystem { - specialArgs = { - inherit - inputs - outputs - hostname - ; - assets = - with lib.haumea; - load { - src = ./assets; - loader = [ - (matchers.always loaders.path) - ]; - }; - secrets = - with lib.haumea; - load { - src = ./secrets; - loader = [ - (matchers.always loaders.path) - ]; - }; - } - // vars; - modules = - (lib.umport { - paths = [ ./modules ]; - exclude = [ - ./modules/virt/types - ]; - recursive = true; - }) - ++ (lib.umport { - paths = [ ./config/hosts/${hostname} ]; - recursive = true; - }) - ++ [ - (lib.mkAliasOptionModule [ "my" "hm" ] [ "home-manager" "users" vars.username ]) - ./config/base.nix - inputs.sops-nix.nixosModules.sops - inputs.impermanence.nixosModules.impermanence - inputs.home-manager.nixosModules.default - inputs.niri.nixosModules.niri - inputs.catppuccin.nixosModules.catppuccin - inputs.angrr.nixosModules.angrr - home - pkgsConf - ]; - } - ); - }; } diff --git a/lib/default.nix b/lib/default.nix index 1034a39..94ffbfb 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,102 +1,10 @@ -{ lib }: - -{ - makeSwitch = - { - default ? false, - config, - optionPath, - optionName, - config', - }: - let - cfg = lib.getAttrFromPath optionPath config.my; - in - { - options.my = lib.setAttrByPath optionPath { - enable = (lib.mkEnableOption optionName) // { - inherit default; - }; - }; - - config = lib.mkIf cfg.enable config'; - }; - - makeHomePackageConfig = - { - config, - pkgs, - packageName, - packagePath, - optionPath, - extraConfig ? { }, - }: - lib.my.makeSwitch { - inherit config optionPath; - optionName = packageName; - config' = lib.mkMerge [ - { - my.hm.home.packages = [ (lib.getAttrFromPath packagePath pkgs) ]; - } - extraConfig - ]; - }; - - makeHomeProgramConfig = - { - config, - programName, - optionPath, - extraConfig ? { }, - }: - lib.my.makeSwitch { - inherit config optionPath; - optionName = programName; - - config' = lib.mkMerge [ - { - my.hm.programs = lib.setAttrByPath [ programName "enable" ] true; - } - extraConfig - ]; - }; - - makeNixosPackageConfig = - { - config, - pkgs, - packageName, - packagePath, - optionPath, - extraConfig ? { }, - }: - lib.my.makeSwitch { - inherit config optionPath; - optionName = packageName; - config' = lib.mkMerge [ - { - environment.systemPackages = [ (lib.getAttrFromPath packagePath pkgs) ]; - } - extraConfig - ]; - }; - - makeNixosProgramConfig = - { - config, - programName, - optionPath, - extraConfig ? { }, - }: - lib.my.makeSwitch { - inherit config optionPath; - optionName = programName; - - config' = lib.mkMerge [ - { - programs = lib.setAttrByPath [ programName "enable" ] true; - } - extraConfig - ]; - }; -} +{ lib, inputs }: +lib.extend ( + self: super: { + my = import ./my.nix { lib = self; }; + umport = import ./umport.nix { lib = self; }; + inherit (inputs.home-manager.lib) hm; + haumea = inputs.haumea.lib; + infuse = (import inputs.infuse { inherit lib; }).v1.infuse; + } +) diff --git a/lib/my.nix b/lib/my.nix new file mode 100644 index 0000000..1034a39 --- /dev/null +++ b/lib/my.nix @@ -0,0 +1,102 @@ +{ lib }: + +{ + makeSwitch = + { + default ? false, + config, + optionPath, + optionName, + config', + }: + let + cfg = lib.getAttrFromPath optionPath config.my; + in + { + options.my = lib.setAttrByPath optionPath { + enable = (lib.mkEnableOption optionName) // { + inherit default; + }; + }; + + config = lib.mkIf cfg.enable config'; + }; + + makeHomePackageConfig = + { + config, + pkgs, + packageName, + packagePath, + optionPath, + extraConfig ? { }, + }: + lib.my.makeSwitch { + inherit config optionPath; + optionName = packageName; + config' = lib.mkMerge [ + { + my.hm.home.packages = [ (lib.getAttrFromPath packagePath pkgs) ]; + } + extraConfig + ]; + }; + + makeHomeProgramConfig = + { + config, + programName, + optionPath, + extraConfig ? { }, + }: + lib.my.makeSwitch { + inherit config optionPath; + optionName = programName; + + config' = lib.mkMerge [ + { + my.hm.programs = lib.setAttrByPath [ programName "enable" ] true; + } + extraConfig + ]; + }; + + makeNixosPackageConfig = + { + config, + pkgs, + packageName, + packagePath, + optionPath, + extraConfig ? { }, + }: + lib.my.makeSwitch { + inherit config optionPath; + optionName = packageName; + config' = lib.mkMerge [ + { + environment.systemPackages = [ (lib.getAttrFromPath packagePath pkgs) ]; + } + extraConfig + ]; + }; + + makeNixosProgramConfig = + { + config, + programName, + optionPath, + extraConfig ? { }, + }: + lib.my.makeSwitch { + inherit config optionPath; + optionName = programName; + + config' = lib.mkMerge [ + { + programs = lib.setAttrByPath [ programName "enable" ] true; + } + extraConfig + ]; + }; +} diff --git a/lib/stdlib-extended.nix b/lib/stdlib-extended.nix deleted file mode 100644 index bd042ee..0000000 --- a/lib/stdlib-extended.nix +++ /dev/null @@ -1,14 +0,0 @@ -# Just a convenience function that returns the given Nixpkgs standard -# library extended with the imxyy library. - -stdlib: - -let - mkMyLib = import ./.; -in -stdlib.extend ( - self: super: { - my = mkMyLib { lib = self; }; - umport = import ./umport.nix { lib = self; }; - } -) diff --git a/modules/cli/misc.nix b/modules/cli/misc.nix index 61c8138..9c3d594 100644 --- a/modules/cli/misc.nix +++ b/modules/cli/misc.nix @@ -16,7 +16,6 @@ lib.my.makeSwitch { environment.systemPackages = with pkgs; [ vim wget - git file gnused @@ -39,8 +38,6 @@ lib.my.makeSwitch { dnsutils killall - - comma ]; programs.dconf.enable = true; @@ -51,16 +48,20 @@ lib.my.makeSwitch { ]; my.hm = { home.packages = with pkgs; [ - lsd - fd - neofetch - fastfetch - fzf - bat - ripgrep - + # keep-sorted start aria2 + bat + comma + fastfetch + fd + fzf + keep-sorted + lsd + neofetch + ripgrep socat + typos + # keep-sorted end ]; programs.tmux = { enable = true; diff --git a/modules/cli/monitor/btop/config/themes/nord.theme b/modules/cli/monitor/btop/config/themes/nord.theme index 07c43c2..fbd0af1 100644 --- a/modules/cli/monitor/btop/config/themes/nord.theme +++ b/modules/cli/monitor/btop/config/themes/nord.theme @@ -18,7 +18,7 @@ theme[main_fg]="#D8DEE9" # Title color for boxes theme[title]="#8FBCBB" -# Higlight color for keyboard shortcuts +# Highlight color for keyboard shortcuts theme[hi_fg]="#5E81AC" # Background color of selected item in processes box diff --git a/modules/cli/shell/fish.nix b/modules/cli/shell/fish.nix index ad49be4..7a05b0c 100644 --- a/modules/cli/shell/fish.nix +++ b/modules/cli/shell/fish.nix @@ -22,6 +22,7 @@ lib.my.makeSwitch { url = "https://raw.githubusercontent.com/folke/tokyonight.nvim/refs/tags/v4.14.1/extras/fish_themes/tokyonight_storm.theme"; sha256 = "02n1w5x65683c8mlwg1rav06iqm3xk90zq45qmygpm7pzyn8dqh1"; }; + programs.starship.enableFishIntegration = false; programs.fish = { enable = true; plugins = [ @@ -34,6 +35,15 @@ lib.my.makeSwitch { hash = "sha256-yef5NX4HdZ3ab/2AzNrvvhi0CbeTvXYKZmyH76gIpyk="; }; } + { + name = "starship"; + src = pkgs.fetchFromGitHub { + owner = "tyler-stefani"; + repo = "starship"; + rev = "fff9bc53ef9997775d31d860246af88cd7721ec8"; + hash = "sha256-S/Vt/jfYTCrMXXfu6YUIv+d0RoT7GYG1isayhtHc7DA="; + }; + } ]; shellAliases = { la = "lsd -lah"; diff --git a/modules/coding/editor/neovim/default.nix b/modules/coding/editor/neovim/default.nix index a5112eb..0279154 100644 --- a/modules/coding/editor/neovim/default.nix +++ b/modules/coding/editor/neovim/default.nix @@ -29,6 +29,8 @@ lib.my.makeHomeProgramConfig { gcc # treesitter ripgrep # telescope + + typos-lsp ]; }; }; diff --git a/modules/coding/editor/neovim/nvim/lua/core/options.lua b/modules/coding/editor/neovim/nvim/lua/core/options.lua index 2df7010..a2a1f1e 100644 --- a/modules/coding/editor/neovim/nvim/lua/core/options.lua +++ b/modules/coding/editor/neovim/nvim/lua/core/options.lua @@ -37,7 +37,7 @@ vim.g.autoread = true vim.g.loaded_ruby_provider = 0 --- Hightlight on yank +-- Highlight on yank local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) vim.api.nvim_create_autocmd("TextYankPost", { callback = function() @@ -55,12 +55,12 @@ vim.cmd([[ \ endif ]]) --- Automaticly switch input method +-- Automatically switch input method Last_input_method = 1 vim.api.nvim_create_augroup("AutoInputMethod", {}) vim.api.nvim_create_autocmd("InsertLeave", { pattern = "*", - desc = "Automaticly switch input method", + desc = "Automatically switch input method", callback = function() Last_input_method = require("core.globals").switch_input_method(1) end, @@ -68,7 +68,7 @@ vim.api.nvim_create_autocmd("InsertLeave", { }) vim.api.nvim_create_autocmd("CmdlineLeave", { pattern = "*", - desc = "Automaticly switch input method", + desc = "Automatically switch input method", callback = function() require("core.globals").switch_input_method(1) end, @@ -76,7 +76,7 @@ vim.api.nvim_create_autocmd("CmdlineLeave", { }) vim.api.nvim_create_autocmd("InsertEnter", { pattern = "*", - desc = "Automaticly switch input method", + desc = "Automatically switch input method", callback = function() require("core.globals").switch_input_method(Last_input_method) end, diff --git a/modules/coding/editor/neovim/nvim/lua/plugins/lsp/lspconfig.lua b/modules/coding/editor/neovim/nvim/lua/plugins/lsp/lspconfig.lua index 662cb99..3fbc40a 100644 --- a/modules/coding/editor/neovim/nvim/lua/plugins/lsp/lspconfig.lua +++ b/modules/coding/editor/neovim/nvim/lua/plugins/lsp/lspconfig.lua @@ -42,7 +42,16 @@ local servers = { command = { "nixfmt" }, }, nixpkgs = { - expr = "import { }", + expr = [[ + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + nodeName = lock.nodes.root.inputs.nixpkgs; + in + import (fetchTarball { + url = lock.nodes.${nodeName}.locked.url or "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz"; + sha256 = lock.nodes.${nodeName}.locked.narHash; + }) { } + ]], }, }, }, @@ -54,14 +63,17 @@ local servers = { qmlls = { cmd = { "qmlls", "-E" }, }, - pyright = {}, - gopls = {}, + -- keep-sorted start clangd = {}, - ts_ls = {}, - jsonls = {}, cssls = {}, + gopls = {}, html = {}, java_language_server = {}, + jsonls = {}, + pyright = {}, + ts_ls = {}, + typos_lsp = {}, + -- keep-sorted end } local capabilities = require("cmp_nvim_lsp").default_capabilities() diff --git a/modules/i18n/fcitx5.nix b/modules/i18n/fcitx5.nix index 05c011a..aaebb63 100644 --- a/modules/i18n/fcitx5.nix +++ b/modules/i18n/fcitx5.nix @@ -25,7 +25,7 @@ lib.my.makeSwitch { settings = { globalOptions = { "PreeditEnabledByDefault"."0" = true; - "Hotkey"."EnumrateWithTriggerKeys" = false; + "Hotkey"."EnumerateWithTriggerKeys" = false; "Hotkey/TriggerKeys"."0" = ""; "Hotkey/AltTriggerKeys"."0" = "Shift_L"; "Hotkey/EnumerateForwardKeys"."0" = ""; diff --git a/modules/nix.nix b/modules/nix.nix index 30c406a..658525f 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -1,5 +1,6 @@ { inputs, + self, config, lib, pkgs, @@ -16,7 +17,7 @@ lib.my.makeSwitch { # This will add each flake input as a registry # To make nix3 commands consistent with your flake nix.registry = (lib.mapAttrs (_: flake: { inherit flake; })) ( - (lib.filterAttrs (_: lib.isType "flake")) inputs + ((lib.filterAttrs (_: lib.isType "flake")) inputs) // { flake = self; } ); # This will additionally add your inputs to the system's legacy channels diff --git a/modules/virt/types/input.nix b/modules/virt/types/input.nix index c164e8a..c082289 100644 --- a/modules/virt/types/input.nix +++ b/modules/virt/types/input.nix @@ -2,7 +2,7 @@ { options = { grabKeyboard = lib.mkOption { - description = "Grab the keybaord in capture mode"; + description = "Grab the keyboard in capture mode"; default = true; type = lib.types.bool; }; diff --git a/modules/virt/types/spice.nix b/modules/virt/types/spice.nix index 474490c..c6330ef 100644 --- a/modules/virt/types/spice.nix +++ b/modules/virt/types/spice.nix @@ -38,7 +38,7 @@ }; clipboardToLocal = lib.mkOption { - description = "Allow the clipbaord to be synchronized FROM the VM"; + description = "Allow the clipboard to be synchronized FROM the VM"; default = true; type = lib.types.bool; }; @@ -56,7 +56,7 @@ }; captureOnStart = lib.mkOption { - description = "Capture mouse and keybaord on start"; + description = "Capture mouse and keyboard on start"; default = false; type = lib.types.bool; }; diff --git a/nixos.nix b/nixos.nix new file mode 100644 index 0000000..19628c5 --- /dev/null +++ b/nixos.nix @@ -0,0 +1,89 @@ +{ + self, + withSystem, + lib, + inputs, + ... +}: +let + forAllHosts = + mkSystem: + lib.mergeAttrsList ( + builtins.map (hostname: { + ${hostname} = mkSystem hostname; + }) (builtins.attrNames (builtins.readDir ./config/hosts)) + ); + pkgsModule = + { config, ... }: + withSystem config.nixpkgs.hostPlatform.system (perSystem: { + nixpkgs.pkgs = perSystem.pkgs; + }); + hmModule = { + home-manager = { + sharedModules = [ + inputs.sops-nix.homeManagerModules.sops + inputs.impermanence.nixosModules.home-manager.impermanence + inputs.stylix.homeModules.stylix + inputs.noctalia.homeModules.default + inputs.zen.homeModules.beta + ]; + useGlobalPkgs = true; + }; + }; + vars = import ./vars.nix; +in +{ + flake.nixosConfigurations = forAllHosts ( + hostname: + lib.nixosSystem { + specialArgs = { + inherit + inputs + self + hostname + ; + assets = + with lib.haumea; + load { + src = ./assets; + loader = [ + (matchers.always loaders.path) + ]; + }; + secrets = + with lib.haumea; + load { + src = ./secrets; + loader = [ + (matchers.always loaders.path) + ]; + }; + } + // vars; + modules = + (lib.umport { + paths = [ ./modules ]; + exclude = [ + ./modules/virt/types + ]; + recursive = true; + }) + ++ (lib.umport { + paths = [ ./config/hosts/${hostname} ]; + recursive = true; + }) + ++ [ + (lib.mkAliasOptionModule [ "my" "hm" ] [ "home-manager" "users" vars.username ]) + ./config/base.nix + inputs.sops-nix.nixosModules.sops + inputs.impermanence.nixosModules.impermanence + inputs.home-manager.nixosModules.default + inputs.niri.nixosModules.niri + inputs.catppuccin.nixosModules.catppuccin + inputs.angrr.nixosModules.angrr + pkgsModule + hmModule + ]; + } + ); +} diff --git a/overlays/default.nix b/overlays/default.nix index b687eeb..95445e4 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,69 +1,27 @@ { inputs, lib, + ... }: +let + mkPkgs = type: final: _prev: { + ${type} = import inputs."nixpkgs-${type}" { + system = final.stdenv.hostPlatform.system; + config.allowUnfree = true; + }; + }; +in { - additions = - final: prev: - lib.haumea.load { - src = ../pkgs; - loader = [ - { - matches = str: builtins.match ".*\\.nix" str != null; - loader = _: path: final.callPackage path { }; - } - ]; - transformer = lib.haumea.transformers.liftDefault; - }; - - modifications = - final: prev: - lib.infuse prev { - cage.__output.patches.__append = [ ./cage-specify-output-name.patch ]; - matrix-synapse.__assign = final.stable.matrix-synapse; - bottles.__input.removeWarningPopup.__assign = true; - - sing-box.__assign = prev.sing-box.overrideAttrs (finalAttrs: { - version = "1.11.14"; - src = final.fetchFromGitHub { - owner = "qjebbs"; - repo = "sing-box"; - # due to faulty tag generation - tag = "v${finalAttrs.version}+rev"; - hash = "sha256-/p2PBTeeRJW3iq/BXJlw/Qn92Nrnw9fmUn5yNGl/o34="; - }; - vendorHash = "sha256-C2HCNOzP1Jg3vz2i9uPmM1wC7Sw2YNt7MdYn939cu1Y="; - postInstall = ""; - }); - }; - - # this allows us to access specific version of nixpkgs - # by `pkgs.unstable`, `pkgs.stable` and `pkgs.master` - unstable-packages = final: _prev: { - unstable = import inputs.nixpkgs-unstable { - system = final.stdenv.hostPlatform.system; - config.allowUnfree = true; - }; - }; - - stable-packages = final: _prev: { - stable = import inputs.nixpkgs-stable { - system = final.stdenv.hostPlatform.system; - config.allowUnfree = true; - }; - }; - - master-packages = final: _prev: { - master = import inputs.nixpkgs-master { - system = final.stdenv.hostPlatform.system; - config.allowUnfree = true; - }; - }; - - working-packages = final: _prev: { - working = import inputs.nixpkgs-working { - system = final.stdenv.hostPlatform.system; - config.allowUnfree = true; - }; - }; + flake.overlays = { + modifications = + final: prev: + lib.infuse prev { + cage.__output.patches.__append = [ ./cage-specify-output-name.patch ]; + bottles.__input.removeWarningPopup.__assign = true; + }; + } + // + # this allows us to access specific version of nixpkgs + # by `pkgs.unstable`, `pkgs.stable` and `pkgs.master` + lib.genAttrs [ "stable" "unstable" "master" ] mkPkgs; } diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..317bf65 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,52 @@ +{ + inputs, + lib, + config, + ... +}: +{ + perSystem = + { system, pkgs, ... }: + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = builtins.attrValues config.flake.overlays ++ [ + inputs.go-musicfox.overlays.default + inputs.niri.overlays.niri + inputs.fenix.overlays.default + inputs.angrr.overlays.default + (final: prev: { + darkly-qt5 = inputs.darkly.packages.${final.stdenv.hostPlatform.system}.darkly-qt5; + darkly-qt6 = inputs.darkly.packages.${final.stdenv.hostPlatform.system}.darkly-qt6; + + noctalia-shell = inputs.noctalia.packages.${final.stdenv.hostPlatform.system}.default; + }) + ]; + config.allowUnfree = true; + flake.setNixPath = false; + }; + + legacyPackages = pkgs; + + packages = lib.genAttrs (builtins.attrNames (config.flake.overlays.additions pkgs pkgs)) ( + pkg: pkgs.${pkg} + ); + }; + + flake.overlays.additions = + final: prev: + let + paths = [ + ./fcitx5-lightly + ./mono-gtk-theme.nix + ./ttf-wps-fonts.nix + ./wps-office-fonts.nix + ]; + in + builtins.listToAttrs ( + map (path: { + name = builtins.elemAt (lib.splitString "." (builtins.baseNameOf path)) 0; + value = final.callPackage path { }; + }) paths + ); +} diff --git a/treefmt.nix b/treefmt.nix index 854c30d..4455358 100644 --- a/treefmt.nix +++ b/treefmt.nix @@ -1,8 +1,16 @@ -{ ... }: +{ inputs, ... }: { - projectRootFile = "flake.nix"; - programs = { - nixfmt.enable = true; - stylua.enable = true; + imports = [ inputs.treefmt.flakeModule ]; + perSystem.treefmt = { + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + stylua.enable = true; + keep-sorted.enable = true; + typos = { + enable = true; + configFile = "typos.toml"; + }; + }; }; } diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..0e670fb --- /dev/null +++ b/typos.toml @@ -0,0 +1,16 @@ +[files] +extend-exclude = [ + "secrets" +] + +[default.extend-words] +# noice.nvim +noice = "noice" +enew = "enew" +iif = "iif" + +[default] +extend-ignore-identifiers-re = [ + "KEY_102ND", + "VE_UE" +]