From b6a705b16c05f502a8fa9edc95d59abe955408ce Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Fri, 10 Mar 2023 19:21:39 -0500 Subject: [PATCH] reworked nixpath/registry --- modules/nix.nix | 51 ++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/modules/nix.nix b/modules/nix.nix index 6108f9f..d498061 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -4,34 +4,39 @@ inputs: { self, settings, ... -}: { +}: let + combined_flakes = + ( + #filter non-flakes from inputs + lib.attrsets.filterAttrs ( + _: value: ( + !(lib.attrsets.hasAttrByPath ["flake"] value) || value.flake == false + ) + ) + inputs + ) + // { + #alias unstable + nixpkgs = inputs.unstable; + #add system flake + system = self; + }; +in { + #create registry from input flakes + nix.registry = lib.attrsets.mapAttrs (_: value: {flake = value;}) combined_flakes; + #add all inputs to etc + environment.etc = lib.mapAttrs' (name: value: lib.attrsets.nameValuePair "/nixpath/${name}" {source = value;}) combined_flakes; + #source the etc paths to nixPath + nix.nixPath = lib.mapAttrsToList (name: _: name + "=" + "/etc/nixpath/${name}") combined_flakes; + + #other nix settings nix = { package = pkgs.nixVersions.unstable; - #automatically get registry from input flakes - registry = ( - lib.attrsets.mapAttrs ( - _: value: { - flake = value; - } - ) ( - lib.attrsets.filterAttrs ( - _: value: ( - !(lib.attrsets.hasAttrByPath ["flake"] value) || value.flake == false - ) - ) - inputs - ) - // { - nixpkgs.flake = inputs.unstable; - system.flake = self; - } - ); - #automatically add registry entries to nixPath - nixPath = (lib.mapAttrsToList (name: value: name + "=" + value) inputs) ++ ["system=${self}" "nixpkgs=${inputs.unstable}"]; settings = { experimental-features = ["nix-command" "flakes" "repl-flake"]; auto-optimise-store = true; warn-dirty = false; + #ignore global registry flake-registry = builtins.toFile "empty-flake-registry.json" ''{"flakes":[],"version":2}''; keep-outputs = true; keep-derivations = true; @@ -43,6 +48,4 @@ inputs: { ]; }; }; - #make gcroots for each flake input - systemd.tmpfiles.rules = lib.attrsets.mapAttrsToList (name: value: "L+ /nix/var/nix/gcroots/${name} - - - - ${value}") inputs; }