diff --git a/flake.nix b/flake.nix index f9beaef0..1e26fa8f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,6 @@ { + description = "kachick's dotfiles that can be placed in the public repository"; + inputs = { # Candidate channels # - https://github.com/kachick/anylang-template/issues/17 @@ -59,6 +61,14 @@ mkNixpkgs = system: if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then nixpkgs-darwin else nixpkgs; + overlays = import ./overlays { inherit edge-nixpkgs; }; + + mkPkgs = + system: + import (mkNixpkgs system) { + inherit system overlays; + }; + mkHomeManager = system: if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then @@ -72,13 +82,6 @@ type = "app"; program = (mkNixpkgs system).lib.getExe pkg; }; - - homemade-packages = forAllSystems ( - system: - ((mkNixpkgs system).legacyPackages.${system}.callPackage ./pkgs { - edge-pkgs = edge-nixpkgs.legacyPackages.${system}; - }) - ); in { # nixfmt will be official @@ -86,13 +89,12 @@ # - https://github.com/NixOS/nixfmt/issues/129 # - https://github.com/NixOS/rfcs/pull/166 # - https://github.com/NixOS/nixfmt/blob/a81f922a2b362f347a6cbecff5fb14f3052bc25d/README.md#L19 - formatter = forAllSystems (system: (mkNixpkgs system).legacyPackages.${system}.nixfmt-rfc-style); + formatter = forAllSystems (system: (mkPkgs system).nixfmt-rfc-style); devShells = forAllSystems ( system: let - pkgs = (mkNixpkgs system).legacyPackages.${system}; - homemade-pkgs = homemade-packages.${system}; + pkgs = mkPkgs system; in { default = pkgs.mkShellNoCC { @@ -134,21 +136,27 @@ (ruby_3_3.withPackages (ps: with ps; [ rubocop ])) ]) - ++ (with homemade-pkgs; [ nix-hash-url ]) + ++ (with pkgs.my; [ nix-hash-url ]) ++ [ inputs.selfup.packages.${system}.default ] )); }; } ); - packages = forAllSystems (system: { - cozette = homemade-packages.${system}.cozette; - micro-kdl = homemade-packages.${system}.micro-kdl; - micro-nordcolors = homemade-packages.${system}.micro-nordcolors; - micro-everforest = homemade-packages.${system}.micro-everforest; - micro-catppuccin = homemade-packages.${system}.micro-catppuccin; - envs = homemade-packages.${system}.envs; - }); + packages = forAllSystems ( + system: + let + pkgs = mkPkgs system; + in + { + cozette = pkgs.my.cozette; + micro-kdl = pkgs.my.micro-kdl; + micro-nordcolors = pkgs.my.micro-nordcolors; + micro-everforest = pkgs.my.micro-everforest; + micro-catppuccin = pkgs.my.micro-catppuccin; + envs = pkgs.my.envs; + } + ); apps = forAllSystems ( system: @@ -158,7 +166,7 @@ inherit name; value = mkApp { system = system; - pkg = homemade-packages.${system}.${name}; + pkg = (mkPkgs system).my.${name}; }; }) [ @@ -203,21 +211,13 @@ nixosConfigurations = let system = "x86_64-linux"; - edge-pkgs = import edge-nixpkgs { - inherit system; - config = { - allowUnfree = true; - }; - }; - homemade-pkgs = homemade-packages.${system}; shared = { inherit system; specialArgs = { inherit inputs outputs - homemade-pkgs - edge-pkgs + overlays ; }; }; @@ -230,127 +230,98 @@ homeConfigurations = let - x86-Linux = { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - extraSpecialArgs = { - homemade-pkgs = homemade-packages.x86_64-linux; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux; - }; - }; - - x86-macOS = { - pkgs = nixpkgs-darwin.legacyPackages.x86_64-darwin; - extraSpecialArgs = { - homemade-pkgs = homemade-packages.x86_64-darwin; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin; - }; - }; + x86-Linux-pkgs = mkPkgs "x86_64-linux"; + x86-macOS-pkgs = mkPkgs "x86_64-darwin"; in { - "kachick@nixos-desktop" = home-manager-linux.lib.homeManagerConfiguration ( - x86-Linux - // { - modules = [ - ./home-manager/kachick.nix - ./home-manager/linux.nix - { targets.genericLinux.enable = false; } - ./home-manager/lima-host.nix - ./home-manager/systemd.nix - ./home-manager/gnome.nix - ./home-manager/firefox.nix - ]; - } - ); + "kachick@nixos-desktop" = home-manager-linux.lib.homeManagerConfiguration ({ + pkgs = x86-Linux-pkgs; + modules = [ + ./home-manager/kachick.nix + ./home-manager/linux.nix + { targets.genericLinux.enable = false; } + ./home-manager/lima-host.nix + ./home-manager/systemd.nix + ./home-manager/gnome.nix + ./home-manager/firefox.nix + ]; + }); - "kachick@wsl-ubuntu" = home-manager-linux.lib.homeManagerConfiguration ( - x86-Linux - // { - modules = [ - ./home-manager/kachick.nix - ./home-manager/linux.nix - ./home-manager/genericLinux.nix - ./home-manager/wsl.nix - ]; - } - ); + "kachick@wsl-ubuntu" = home-manager-linux.lib.homeManagerConfiguration ({ + pkgs = x86-Linux-pkgs; + modules = [ + ./home-manager/kachick.nix + ./home-manager/linux.nix + ./home-manager/genericLinux.nix + ./home-manager/wsl.nix + ]; + }); - "nixos@wsl-nixos" = home-manager-linux.lib.homeManagerConfiguration ( - x86-Linux - // { - modules = [ - ./home-manager/kachick.nix - ./home-manager/linux.nix - { - home.username = "nixos"; - targets.genericLinux.enable = false; - } - ./home-manager/wsl.nix - ]; - } - ); + "nixos@wsl-nixos" = home-manager-linux.lib.homeManagerConfiguration ({ + pkgs = x86-Linux-pkgs; + modules = [ + ./home-manager/kachick.nix + ./home-manager/linux.nix + { + home.username = "nixos"; + targets.genericLinux.enable = false; + } + ./home-manager/wsl.nix + ]; + }); - "kachick@macbook" = home-manager-darwin.lib.homeManagerConfiguration ( - x86-macOS - // { - modules = [ - ./home-manager/kachick.nix - ./home-manager/darwin.nix - ]; - } - ); + "kachick@macbook" = home-manager-darwin.lib.homeManagerConfiguration ({ + pkgs = x86-macOS-pkgs; + modules = [ + ./home-manager/kachick.nix + ./home-manager/darwin.nix + ]; + }); - "kachick@lima" = home-manager-darwin.lib.homeManagerConfiguration ( - x86-Linux - // { - modules = [ - ./home-manager/kachick.nix - ./home-manager/linux.nix - ./home-manager/genericLinux.nix - ./home-manager/lima-guest.nix - ]; - } - ); + "kachick@lima" = home-manager-darwin.lib.homeManagerConfiguration ({ + pkgs = x86-Linux-pkgs; + modules = [ + ./home-manager/kachick.nix + ./home-manager/linux.nix + ./home-manager/genericLinux.nix + ./home-manager/lima-guest.nix + ]; + }); - "github-actions@ubuntu-24.04" = home-manager-linux.lib.homeManagerConfiguration ( - x86-Linux - // { - # Prefer "kachick" over "common" only here. - # Using values as much as possible as actual values to create a robust CI - modules = [ - ./home-manager/kachick.nix - ./home-manager/linux.nix - { home.username = "runner"; } - ./home-manager/genericLinux.nix - ./home-manager/systemd.nix - ]; - } - ); + "github-actions@ubuntu-24.04" = home-manager-linux.lib.homeManagerConfiguration ({ + pkgs = x86-Linux-pkgs; + # Prefer "kachick" over "common" only here. + # Using values as much as possible as actual values to create a robust CI + modules = [ + ./home-manager/kachick.nix + ./home-manager/linux.nix + { home.username = "runner"; } + ./home-manager/genericLinux.nix + ./home-manager/systemd.nix + ]; + }); - "github-actions@macos-13" = home-manager-darwin.lib.homeManagerConfiguration ( - x86-macOS - // { - # Prefer "kachick" over "common" only here. - # Using values as much as possible as actual values to create a robust CI - modules = [ - ./home-manager/kachick.nix - ./home-manager/darwin.nix - { home.username = "runner"; } - ]; - } - ); + "github-actions@macos-13" = home-manager-darwin.lib.homeManagerConfiguration ({ + pkgs = x86-macOS-pkgs; + # Prefer "kachick" over "common" only here. + # Using values as much as possible as actual values to create a robust CI + modules = [ + ./home-manager/kachick.nix + ./home-manager/darwin.nix + { home.username = "runner"; } + ]; + }); - "user@linux-cli" = home-manager-linux.lib.homeManagerConfiguration ( - x86-Linux - // { - modules = [ - ./home-manager/common.nix - { home.username = "user"; } - ./home-manager/linux.nix - ./home-manager/genericLinux.nix - ./home-manager/systemd.nix - ]; - } - ); + "user@linux-cli" = home-manager-linux.lib.homeManagerConfiguration ({ + pkgs = x86-Linux-pkgs; + modules = [ + ./home-manager/common.nix + { home.username = "user"; } + ./home-manager/linux.nix + ./home-manager/genericLinux.nix + ./home-manager/systemd.nix + ]; + }); }; }; } diff --git a/home-manager/bash.nix b/home-manager/bash.nix index e2c60865..13047de1 100644 --- a/home-manager/bash.nix +++ b/home-manager/bash.nix @@ -2,7 +2,6 @@ config, lib, pkgs, - homemade-pkgs, ... }: @@ -133,7 +132,7 @@ # Disable `Ctrl + S(no output tty)` ${lib.getBin pkgs.coreutils}/bin/stty stop undef - source "${homemade-pkgs.posix_shared_functions}" + source "${pkgs.my.posix_shared_functions}" if [ 'linux' = "$TERM" ]; then # Avoid Tofu diff --git a/home-manager/common.nix b/home-manager/common.nix index d300684f..44dc8eec 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -2,8 +2,6 @@ config, pkgs, lib, - edge-pkgs, - homemade-pkgs, ... }: @@ -68,8 +66,6 @@ packages = import ./packages.nix { inherit pkgs; - inherit edge-pkgs; - inherit homemade-pkgs; }; # You can check the candidates in `locale -a` diff --git a/home-manager/darwin.nix b/home-manager/darwin.nix index 03ca0854..03a30eb5 100644 --- a/home-manager/darwin.nix +++ b/home-manager/darwin.nix @@ -1,6 +1,5 @@ { - pkgs, - # Don't depend on edge-pkgs as possible until realize https://github.com/NixOS/nixpkgs/issues/107466, + pkgs, # Don't depend on edge-pkgs as possible until realize https://github.com/NixOS/nixpkgs/issues/107466, config, ... }: diff --git a/home-manager/git.nix b/home-manager/git.nix index d155a434..c3681e07 100644 --- a/home-manager/git.nix +++ b/home-manager/git.nix @@ -1,6 +1,5 @@ { pkgs, - homemade-pkgs, lib, ... }: @@ -41,7 +40,7 @@ in upstream = "!git remote | grep -E '^upstream$'|| git remote | grep -E '^origin$'"; refresh = "!git remote update origin --prune && git switch-default && git pull --prune \"$(git upstream)\" \"$(git current)\""; all = "!git refresh && git-delete-merged-branches"; - lf = "!${lib.getExe homemade-pkgs.git-log-fzf}"; + lf = "!${lib.getExe pkgs.my.git-log-fzf}"; reset-main = '' !git fetch origin && \ git switch main && \ @@ -49,16 +48,16 @@ in git checkout origin/main && \ git checkout -b main ''; - resolve-conflict = "!${lib.getExe homemade-pkgs.git-resolve-conflict}"; + resolve-conflict = "!${lib.getExe pkgs.my.git-resolve-conflict}"; }; # Required to provide all global hooks to respect local hooks even if it is empty. See GH-545 for detail # Candidates: https://github.com/git/git/tree/v2.44.1/templates hooks = { - commit-msg = lib.getExe homemade-pkgs.git-hooks-commit-msg; + commit-msg = lib.getExe pkgs.my.git-hooks-commit-msg; # Git does not provide hooks for renaming branch, so using in checkout phase is not enough - pre-push = lib.getExe homemade-pkgs.git-hooks-pre-push; + pre-push = lib.getExe pkgs.my.git-hooks-pre-push; pre-merge-commit = lib.getExe (mkPassthruHook "pre-merge-commit"); pre-applypatch = lib.getExe (mkPassthruHook "pre-applypatch"); @@ -200,6 +199,6 @@ in ]; }; - extensions = (with pkgs; [ gh-poi ]) ++ (with homemade-pkgs; [ gh-prs ]); + extensions = (with pkgs; [ gh-poi ]) ++ (with pkgs.my; [ gh-prs ]); }; } diff --git a/home-manager/linux.nix b/home-manager/linux.nix index 71e73fab..451f6cbc 100644 --- a/home-manager/linux.nix +++ b/home-manager/linux.nix @@ -2,7 +2,6 @@ config, pkgs, lib, - homemade-pkgs, ... }: @@ -39,7 +38,7 @@ # Keybindigs: https://git.sr.ht/~bptato/chawan/tree/master/item/res/config.toml chawan # `cha` - homemade-pkgs.renmark # Depend on chawan + pkgs.my.renmark # Depend on chawan ]; }; diff --git a/home-manager/micro.nix b/home-manager/micro.nix index 65feadf7..90dc1f5a 100644 --- a/home-manager/micro.nix +++ b/home-manager/micro.nix @@ -1,7 +1,6 @@ { lib, pkgs, - homemade-pkgs, ... }: @@ -13,14 +12,14 @@ # For temporal use xdg.configFile."micro/colorschemes/.keep".text = ""; - xdg.configFile."micro/plug/fzfinder".source = homemade-pkgs.micro-fzfinder; - xdg.configFile."micro/plug/kdl".source = homemade-pkgs.micro-kdl; - xdg.configFile."micro/plug/nordcolors".source = homemade-pkgs.micro-nordcolors; + xdg.configFile."micro/plug/fzfinder".source = pkgs.my.micro-fzfinder; + xdg.configFile."micro/plug/kdl".source = pkgs.my.micro-kdl; + xdg.configFile."micro/plug/nordcolors".source = pkgs.my.micro-nordcolors; xdg.configFile."micro/colorschemes" = { - source = "${homemade-pkgs.micro-catppuccin}/colorschemes"; + source = "${pkgs.my.micro-catppuccin}/colorschemes"; recursive = true; }; - xdg.configFile."micro/colorschemes/everforest.micro".source = "${homemade-pkgs.micro-everforest}/colorschemes/everforest.micro"; + xdg.configFile."micro/colorschemes/everforest.micro".source = "${pkgs.my.micro-everforest}/colorschemes/everforest.micro"; # Default keybinfings are https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md xdg.configFile."micro/bindings.json".source = ../config/micro/bindings.json; diff --git a/home-manager/packages.nix b/home-manager/packages.nix index a163093f..32f6f4af 100644 --- a/home-manager/packages.nix +++ b/home-manager/packages.nix @@ -1,6 +1,5 @@ { pkgs, - homemade-pkgs, ... }: @@ -55,7 +54,7 @@ # - https://discourse.nixos.org/t/home-manager-neovim-collision/16963/2 micro - ox # modeless editor. TODO: Consider to use edge-pkgs version because of it is frequently updated + unstable.ox # modeless editor. tree eza # alt ls @@ -105,7 +104,7 @@ # - Apertium - does not support Japanese translate-shell # `echo "$text" | trans en:ja` ]) -++ (with homemade-pkgs; [ +++ (with pkgs.my; [ la lat fzf-bind-posix-shell-history-to-git-commit-message diff --git a/home-manager/zsh.nix b/home-manager/zsh.nix index 808d7490..50a48a58 100644 --- a/home-manager/zsh.nix +++ b/home-manager/zsh.nix @@ -2,7 +2,6 @@ config, lib, pkgs, - homemade-pkgs, ... }: @@ -291,7 +290,7 @@ in . "$@" } - source_sh "${homemade-pkgs.posix_shared_functions}" + source_sh "${pkgs.my.posix_shared_functions}" if [ 'linux' = "$TERM" ]; then # Avoid Tofu diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 39fd10d6..4e8cb2c1 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -4,13 +4,13 @@ { pkgs, - homemade-pkgs, lib, + overlays, ... }: { imports = [ - (import ./console.nix { inherit homemade-pkgs; }) + (import ./console.nix { inherit pkgs; }) ]; nix.settings.experimental-features = [ @@ -49,9 +49,13 @@ # TODO: Reconsider to set UTC for servers time.timeZone = "Asia/Tokyo"; - # Allow unfree packages - # Be careful to deploy containers if true, and it may take longtime in CI for non binary caches - nixpkgs.config.allowUnfree = true; + nixpkgs = { + inherit overlays; + + # Allow unfree packages + # Be careful to deploy containers if true, and it may take longtime in CI for non binary caches + config.allowUnfree = true; + }; # https://github.com/NixOS/nixpkgs/blob/8e5e5a6add04c7f1e38e76f59ada6732947f1e55/nixos/doc/manual/release-notes/rl-2411.section.md?plain=1#L69-L76 # Disabling to avoid `SC2174` in for '/nix/store/h93h6srxzslr8kyv13klrq63zd6ymhxy-unit-script-cups-pre-start.drv' diff --git a/nixos/console.nix b/nixos/console.nix index 6ccdfd5f..9ff1f8c4 100644 --- a/nixos/console.nix +++ b/nixos/console.nix @@ -1,4 +1,4 @@ -{ homemade-pkgs, ... }: +{ pkgs, ... }: { # https://github.com/NixOS/nixpkgs/blob/nixos-24.11/nixos/modules/config/console.nix # https://wiki.archlinux.org/title/Linux_console @@ -6,9 +6,9 @@ earlySetup = true; # The font should have PSF formats. Do not specify TTF and OTF # You can list current glyphs with `showconsolefont` - font = "${homemade-pkgs.cozette}/share/consolefonts/cozette_hidpi.psf"; + font = "${pkgs.my.cozette}/share/consolefonts/cozette_hidpi.psf"; - packages = with homemade-pkgs; [ cozette ]; + packages = with pkgs.my; [ cozette ]; keyMap = "us"; # Applying iceberg for 16(0-15) console colors diff --git a/nixos/desktop/default.nix b/nixos/desktop/default.nix index b3a081c5..37ad480d 100644 --- a/nixos/desktop/default.nix +++ b/nixos/desktop/default.nix @@ -2,14 +2,13 @@ config, inputs, pkgs, - homemade-pkgs, lib, ... }: { imports = [ - (import ./font.nix { inherit pkgs homemade-pkgs; }) + (import ./font.nix { inherit pkgs; }) inputs.xremap-flake.nixosModules.default ./xremap.nix ]; diff --git a/nixos/desktop/font.nix b/nixos/desktop/font.nix index e1149cd9..edf96b9b 100644 --- a/nixos/desktop/font.nix +++ b/nixos/desktop/font.nix @@ -1,4 +1,4 @@ -{ pkgs, homemade-pkgs, ... }: +{ pkgs, ... }: { fonts = { enableDefaultPackages = true; @@ -30,7 +30,7 @@ ]) ++ [ # emoji - homemade-pkgs.beedii + pkgs.my.beedii ]; # Same as home-manager module? diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 00000000..73b12aba --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,14 @@ +{ edge-nixpkgs, ... }: +[ + (final: _prev: { + my = import ../pkgs { + pkgs = final.pkgs; + }; + }) + + (final: _prev: { + unstable = import edge-nixpkgs { + system = final.system; + }; + }) +]