1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

nixos module: support users.users.<name?>.home-manager

This commit is contained in:
Robert Helgesson 2018-08-01 22:55:55 +02:00
parent 99c900946d
commit c517313f7e
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

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);
}; };
} }