mirror of
https://github.com/nix-community/home-manager
synced 2024-11-19 09:39:45 +01:00
nixos,darwin: add sharedModules and extraSpecialArgs options (#1793)
This allows users of the nixos and nix-darwin module to set shared modules for all users and extra specialArgs to be available to home-manager modules. The latter is named extraSpecialArgs just like the argument to modules/default.nix. This could be confusing since the the two are independent in code, but they do mean the same thing so I think the name fits. Darwin can now refer to the global system configuration if used as a module through the special `darwinConfig` argument. Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
This commit is contained in:
parent
eb3a0342a8
commit
82d6ba7003
2 changed files with 43 additions and 4 deletions
|
@ -9,7 +9,10 @@ let
|
|||
extendedLib = import ../modules/lib/stdlib-extended.nix pkgs.lib;
|
||||
|
||||
hmModule = types.submoduleWith {
|
||||
specialArgs = { lib = extendedLib; };
|
||||
specialArgs = {
|
||||
lib = extendedLib;
|
||||
darwinConfig = config;
|
||||
} // cfg.extraSpecialArgs;
|
||||
modules = [
|
||||
({ name, ... }: {
|
||||
imports = import ../modules/modules.nix {
|
||||
|
@ -26,7 +29,7 @@ let
|
|||
home.homeDirectory = config.users.users.${name}.home;
|
||||
};
|
||||
})
|
||||
];
|
||||
] ++ cfg.sharedModules;
|
||||
};
|
||||
|
||||
in
|
||||
|
@ -55,6 +58,24 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
extraSpecialArgs = mkOption {
|
||||
type = types.attrs;
|
||||
default = { };
|
||||
example = literalExample "{ modulesPath = ../modules; }";
|
||||
description = ''
|
||||
Extra <literal>specialArgs</literal> passed to Home Manager.
|
||||
'';
|
||||
};
|
||||
|
||||
sharedModules = mkOption {
|
||||
type = with types; listOf (oneOf [ attrs (functionTo attrs) path ]);
|
||||
default = [ ];
|
||||
example = literalExample "[ { home.packages = [ nixpkgs-fmt ]; } ]";
|
||||
description = ''
|
||||
Extra modules added to all users.
|
||||
'';
|
||||
};
|
||||
|
||||
verbose = mkEnableOption "verbose output on activation";
|
||||
|
||||
users = mkOption {
|
||||
|
|
|
@ -12,7 +12,7 @@ let
|
|||
specialArgs = {
|
||||
lib = extendedLib;
|
||||
nixosConfig = config;
|
||||
};
|
||||
} // cfg.extraSpecialArgs;
|
||||
modules = [
|
||||
({ name, ... }: {
|
||||
imports = import ../modules/modules.nix {
|
||||
|
@ -34,7 +34,7 @@ let
|
|||
home.homeDirectory = config.users.users.${name}.home;
|
||||
};
|
||||
})
|
||||
];
|
||||
] ++ cfg.sharedModules;
|
||||
};
|
||||
|
||||
serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
|
||||
|
@ -65,6 +65,24 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
extraSpecialArgs = mkOption {
|
||||
type = types.attrs;
|
||||
default = { };
|
||||
example = literalExample "{ modulesPath = ../modules; }";
|
||||
description = ''
|
||||
Extra <literal>specialArgs</literal> passed to Home Manager.
|
||||
'';
|
||||
};
|
||||
|
||||
sharedModules = mkOption {
|
||||
type = with types; listOf (oneOf [ attrs (functionTo attrs) path ]);
|
||||
default = [ ];
|
||||
example = literalExample "[ { home.packages = [ nixpkgs-fmt ]; } ]";
|
||||
description = ''
|
||||
Extra modules added to all users.
|
||||
'';
|
||||
};
|
||||
|
||||
verbose = mkEnableOption "verbose output on activation";
|
||||
|
||||
users = mkOption {
|
||||
|
|
Loading…
Reference in a new issue