diff --git a/default.nix b/default.nix index 76ac5332..d34d49c6 100644 --- a/default.nix +++ b/default.nix @@ -1,8 +1,7 @@ { pkgs ? import { } }: let - lib' = pkgs.lib.extend (final: prev: - import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; }); + lib' = pkgs.lib.extend (import ./lib/extras/extend-lib.nix); in { lib = import ./lib { lib = pkgs.lib; }; diff --git a/flake.nix b/flake.nix index 205844b7..461f2e2f 100644 --- a/flake.nix +++ b/flake.nix @@ -87,7 +87,7 @@ users = lib'.importTOML ./users.toml; # A set of image-related utilities for the flake outputs. - inherit (import ./lib/images.nix { inherit inputs; lib = lib'; }) mkHost mkHome mkImage listImagesWithSystems; + inherit (import ./lib/extras/images.nix { inherit inputs; lib = lib'; }) mkHost mkHome mkImage listImagesWithSystems; # The order here is important(?). overlays = [ diff --git a/lib/extras/extend-lib.nix b/lib/extras/extend-lib.nix new file mode 100644 index 00000000..664e7f8a --- /dev/null +++ b/lib/extras/extend-lib.nix @@ -0,0 +1,16 @@ +# A lambda suitable to be used for `pkgs.lib.extend`. +self: super: let + publicLib = import ../. { lib = super; }; +in +{ + inherit (publicLib) filesToAttr countAttrs getSecrets + attachSopsPathPrefix; + + # Until I figure out how to properly add them only for their respective + # environment, this is the working solution for now. Not really perfect + # since we use one nixpkgs instance for each configuration (home-manager or + # otherwise). + private = publicLib + // import ../private.nix { lib = self; } + // import ../home-manager.nix { lib = self; }; +} diff --git a/lib/images.nix b/lib/extras/images.nix similarity index 91% rename from lib/images.nix rename to lib/extras/images.nix index f90f8d34..5fb6403a 100644 --- a/lib/images.nix +++ b/lib/extras/images.nix @@ -4,15 +4,7 @@ let # A function that generates a lambda suitable for `lib.extend`. - extendLib = self: super: let - publicLib = import ./. { lib = super; }; - in - { - inherit (publicLib) filesToAttr countAttrs getSecrets - attachSopsPathPrefix; - private = publicLib - // import ./private.nix { lib = self; }; - }; + extendLib = import ./extend-lib.nix; in { # A thin wrapper around the NixOS configuration function.