1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-26 16:38:34 +02:00

home-manager: add extendModules attribute

The `home-manager.lib.homeManagerConfiguration` function now has an
additional attribute that can be used to extend a Home Manager
configuration with additional modules outside the project tree.

It works similar to the result of `lib.nixosSystem` from Nixpkgs
This commit is contained in:
GrizzlT 2024-01-24 11:30:39 +01:00 committed by Robert Helgesson
parent c82e52b0d9
commit c7ce343d9b
No known key found for this signature in database
GPG Key ID: 96E745BD17AA17ED

View File

@ -28,17 +28,20 @@ let
specialArgs = { modulesPath = builtins.toString ./.; } // extraSpecialArgs;
};
module = showWarnings (let
failed = collectFailed rawModule.config;
moduleChecks = raw:
showWarnings (let
failed = collectFailed raw.config;
failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
in if failed == [ ] then
rawModule
raw
else
throw ''
Failed assertions:
${failedStr}'');
withExtraAttrs = rawModule:
let module = moduleChecks rawModule;
in {
inherit (module) options config;
@ -52,4 +55,7 @@ in {
(filter (a: a.condition) rawModule.config.news.entries);
inherit (module._module.args) pkgs;
}
extendModules = args: withExtraAttrs (rawModule.extendModules args);
};
in withExtraAttrs rawModule