mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
nixos module: support users.users.<name?>.home-manager
This commit is contained in:
parent
99c900946d
commit
c517313f7e
1 changed files with 18 additions and 12 deletions
|
@ -4,7 +4,7 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.home-manager;
|
cfg = config.users;
|
||||||
|
|
||||||
hmModule = types.submodule ({name, ...}: {
|
hmModule = types.submodule ({name, ...}: {
|
||||||
imports = import ../modules/modules.nix {
|
imports = import ../modules/modules.nix {
|
||||||
|
@ -13,8 +13,8 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
home.username = config.users.users.${name}.name;
|
home.username = cfg.users.${name}.name;
|
||||||
home.homeDirectory = config.users.users.${name}.home;
|
home.homeDirectory = cfg.users.${name}.home;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,16 +22,22 @@ in
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
home-manager.users = mkOption {
|
users.users = mkOption {
|
||||||
type = types.attrsOf hmModule;
|
options = [
|
||||||
default = {};
|
{
|
||||||
description = ''
|
home-manager = mkOption {
|
||||||
Per-user Home Manager configuration.
|
type = types.attrsOf hmModule;
|
||||||
'';
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Per-user Home Manager configuration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (cfg.users != {}) {
|
config = {
|
||||||
systemd.services = mapAttrs' (username: usercfg:
|
systemd.services = mapAttrs' (username: usercfg:
|
||||||
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
||||||
description = "Home Manager environment for ${username}";
|
description = "Home Manager environment for ${username}";
|
||||||
|
@ -50,10 +56,10 @@ in
|
||||||
ExecStart = pkgs.writeScript "activate-${username}" ''
|
ExecStart = pkgs.writeScript "activate-${username}" ''
|
||||||
#! ${pkgs.stdenv.shell} -el
|
#! ${pkgs.stdenv.shell} -el
|
||||||
echo Activating home-manager configuration for ${username}
|
echo Activating home-manager configuration for ${username}
|
||||||
exec ${usercfg.home.activationPackage}/activate
|
exec ${usercfg.home-manager.home.activationPackage}/activate
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
) cfg.users;
|
) (filterAttrs (n: v: v ? home-manager) cfg.users);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue