diff --git a/modules/base/nix/default.nix b/modules/base/nix/default.nix index 3e8021c9..9b2d737d 100644 --- a/modules/base/nix/default.nix +++ b/modules/base/nix/default.nix @@ -4,6 +4,7 @@ ./environment.nix # environment settings that nix requires ./nix.nix # nix the package manager's settings ./plugins.nix # nix plugins + ./registry.nix # the nix registry ./substituters.nix # nixpkgs substituters # keep-sorted end ]; diff --git a/modules/base/nix/nix.nix b/modules/base/nix/nix.nix index 6bffbdb3..704947ce 100644 --- a/modules/base/nix/nix.nix +++ b/modules/base/nix/nix.nix @@ -3,18 +3,12 @@ pkgs, _class, config, - inputs, inputs', ... }: let - inherit (lib.attrsets) filterAttrs attrValues mapAttrs; - inherit (lib.modules) mkForce; - inherit (lib.types) isType; inherit (lib.lists) optionals; - flakeInputs = filterAttrs (name: value: (isType "flake" value) && (name != "self")) inputs; - sudoers = if (_class == "nixos") then "@wheel" else "@admin"; in { @@ -30,19 +24,6 @@ in package = inputs'.izlix.packages.lix; # package = pkgs.nixVersions.latest; - # pin the registry to avoid downloading and evaluating a new nixpkgs version everytime - registry = (mapAttrs (_: flake: { inherit flake; }) flakeInputs) // { - # https://github.com/NixOS/nixpkgs/pull/388090 - nixpkgs = lib.mkForce { flake = inputs.nixpkgs; }; - }; - - # We love legacy support (for now) - nixPath = - if (_class == "nixos") then - attrValues (mapAttrs (k: v: "${k}=flake:${v.outPath}") flakeInputs) - else - mkForce (mapAttrs (_: v: v.outPath) flakeInputs); - # set up garbage collection to run , and removing packages after 3 days gc = { automatic = true; diff --git a/modules/base/nix/registry.nix b/modules/base/nix/registry.nix new file mode 100644 index 00000000..81578b58 --- /dev/null +++ b/modules/base/nix/registry.nix @@ -0,0 +1,28 @@ +{ lib, inputs, ... }: +let + inherit (lib.attrsets) filterAttrs attrValues mapAttrs; + inherit (lib.modules) mkForce; + inherit (lib.types) isType; + + flakeInputs = filterAttrs (name: value: (isType "flake" value) && (name != "self")) inputs; +in +{ + # The path to the nixpkgs sources used to build the system. This is + # automatically set up to be the store path of the nixpkgs flake used to + # build the system if using lib.nixosSystem, and is otherwise null by + # default. + # + # now i actually set this back to null, because i want to do what this pr + # does basically. nowhere is this option really used outside of the one + # module so i can pretty much just null it and be fine + # https://github.com/NixOS/nixpkgs/pull/388090 + nixpkgs.flake.source = mkForce null; + + # now the explanation is done above we can pin our nixpkgs and inputs + # however we like + nix = { + # pin to avoid downloading and evaluating a new inputs everytime + registry = mapAttrs (_: flake: { inherit flake; }) flakeInputs; + nixPath = attrValues (mapAttrs (k: v: "${k}=flake:${v.outPath}") flakeInputs); + }; +} diff --git a/modules/flake/lib/mkhost.nix b/modules/flake/lib/mkhost.nix index cf66d92f..08521f16 100644 --- a/modules/flake/lib/mkhost.nix +++ b/modules/flake/lib/mkhost.nix @@ -92,17 +92,9 @@ evalHost { key = "dotfiles#nixpkgs"; _file = "${__curPos.file}"; - nixpkgs = { - # you can also do this as `inherit system;` with the normal `lib.nixosSystem` - # however for evalModules this will not work, so we do this instead - hostPlatform = system; - - # The path to the nixpkgs sources used to build the system. - # This is automatically set up to be the store path of the nixpkgs flake used to build - # the system if using lib.nixosSystem, and is otherwise null by default. - # so that means that we should set it to our nixpkgs flake output path - flake.source = nixpkgs.outPath; - }; + # you can also do this as `inherit system;` with the normal `lib.nixosSystem` + # however for evalModules this will not work, so we do this instead + nixpkgs.hostPlatform = system; } ] # if we are on darwin we need to import the nixpkgs source, its used in some