diff --git a/configs/flake-parts/default.nix b/configs/flake-parts/default.nix index 60c067ae..ebe6f8a8 100644 --- a/configs/flake-parts/default.nix +++ b/configs/flake-parts/default.nix @@ -17,30 +17,6 @@ _module.args = { # This will be shared among NixOS and home-manager configurations. defaultNixConf = { config, lib, pkgs, ... }: { - # I want to capture the usual flakes to its exact version so we're - # making them available to our system. This will also prevent the - # annoying downloads since it always get the latest revision. - nix.registry = - lib.mapAttrs' - (name: flake: - let - name' = if (name == "self") then "config" else name; - in - lib.nameValuePair name' { inherit flake; }) - inputs; - - nix.settings.nix-path = - (lib.mapAttrsToList - (name: source: - let - name' = if (name == "self") then "config" else name; - in - "${name'}=${source}") - inputs - ++ [ - "/nix/var/nix/profiles/per-user/root/channels" - ]); - # Extend nixpkgs with our overlays except for the NixOS-focused modules # here. nixpkgs.overlays = lib.attrValues inputs.self.overlays; diff --git a/modules/flake-parts/setups/home-manager.nix b/modules/flake-parts/setups/home-manager.nix index 1ecf8ff1..afb092ff 100644 --- a/modules/flake-parts/setups/home-manager.nix +++ b/modules/flake-parts/setups/home-manager.nix @@ -200,6 +200,7 @@ in type = with lib.types; attrsOf (submoduleWith { specialArgs = { inherit (config) systems; }; modules = [ + (import ./shared/nix-conf.nix { inherit inputs; }) ./shared/nixvim-instance-options.nix ./shared/config-options.nix configType diff --git a/modules/flake-parts/setups/nixos.nix b/modules/flake-parts/setups/nixos.nix index 52642646..1a8b187c 100644 --- a/modules/flake-parts/setups/nixos.nix +++ b/modules/flake-parts/setups/nixos.nix @@ -459,11 +459,6 @@ let { nixpkgs.overlays = setupConfig.overlays; networking.hostName = lib.mkDefault setupConfig.hostname; - - nix.settings.nix-path = lib.mkBefore [ - "home-manager=${inputs.${setupConfig.homeManagerBranch}}" - "nixpkgs=${inputs.${setupConfig.nixpkgsBranch}}" - ]; } (lib.mkIf (setupConfig.domain != null) { @@ -489,6 +484,7 @@ in type = with lib.types; attrsOf (submoduleWith { specialArgs = { inherit (config) systems; }; modules = [ + (import ./shared/nix-conf.nix { inherit inputs; }) ./shared/config-options.nix ./shared/nixvim-instance-options.nix configType diff --git a/modules/flake-parts/setups/shared/nix-conf.nix b/modules/flake-parts/setups/shared/nix-conf.nix new file mode 100644 index 00000000..e2a4a8a5 --- /dev/null +++ b/modules/flake-parts/setups/shared/nix-conf.nix @@ -0,0 +1,39 @@ +{ inputs }: + +{ config, lib, ... }: + +let + inputs' = inputs // { + nixpkgs = inputs.${config.nixpkgsBranch}; + home-manager = inputs.${config.homeManagerBranch}; + }; +in +{ + config.modules = [( + { lib, ... }: { + # I want to capture the usual flakes to its exact version so we're + # making them available to our system. This will also prevent the + # annoying downloads since it always get the latest revision. + nix.registry = + lib.mapAttrs' + (name: flake: + let + name' = if (name == "self") then "config" else name; + in + lib.nameValuePair name' { inherit flake; }) + inputs'; + + nix.settings.nix-path = + (lib.mapAttrsToList + (name: source: + let + name' = if (name == "self") then "config" else name; + in + "${name'}=${source}") + inputs' + ++ [ + "/nix/var/nix/profiles/per-user/root/channels" + ]); + } + )]; +}