Compare commits

...

1 commit

Author SHA1 Message Date
Robert Helgesson c517313f7e
nixos module: support users.users.<name?>.home-manager 2018-08-01 23:09:03 +02:00

View file

@ -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 {
options = [
{
home-manager = mkOption {
type = types.attrsOf hmModule; type = types.attrsOf hmModule;
default = {}; default = {};
description = '' description = ''
Per-user Home Manager configuration. 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);
}; };
} }