lib: make extraSpecialArgs in mkUser

There are now other user configs that make use of different attributes
from the flake itself. It is better to make `extraSpecialArgs`
configurable at this point.
This commit is contained in:
Gabriel Arazas 2022-03-01 23:05:20 +08:00
parent 3c2d1a1cdf
commit 0dbea86e46
2 changed files with 11 additions and 6 deletions

View File

@ -160,8 +160,16 @@
};
# The default config for our home-manager configurations.
userDefaultConfig = {
userDefaultConfig = let
system = "x86_64-linux";
in {
inherit system;
specialArgs = {
inherit system self;
lib = nixpkgs.lib.extend (final: prev:
import ./lib { lib = prev; });
};
extraModules = [{
# To be able to use the most of our config as possible, we want both to

View File

@ -69,20 +69,17 @@ in rec {
*/
mkUser = file:
attrs@{ username ? (builtins.baseNameOf file), system ? sys
, extraModules ? [ ], ... }:
, extraModules ? [ ], extraSpecialArgs ? { inherit lib system; }, ... }:
let
hmConfigFunctionArgs = builtins.attrNames (builtins.functionArgs
inputs.home-manager.lib.homeManagerConfiguration);
hmModules = lib.map (path: import path)
(lib.modulesToList (lib.filesToAttrRec ../modules/home-manager));
in inputs.home-manager.lib.homeManagerConfiguration {
inherit system username;
inherit system username extraSpecialArgs;
configuration = import file;
homeDirectory = "/home/${username}";
extraModules = hmModules ++ extraModules
++ [ (lib.filterAttrs (n: _: !lib.elem n hmConfigFunctionArgs) attrs) ];
# Additional attributes to be referred to the modules.
extraSpecialArgs = { inherit lib system; };
};
}