mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
nixos: use usercfg.home.username for username
Use `usercfg.home.username` for username instead of attribute name, as this way we can change username regardless of the name of the attribute.
This commit is contained in:
parent
d726afd9e4
commit
2e13c3cdfd
1 changed files with 23 additions and 20 deletions
|
@ -60,28 +60,31 @@ in
|
|||
}) cfg.users
|
||||
);
|
||||
|
||||
systemd.services = mapAttrs' (username: usercfg:
|
||||
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
||||
description = "Home Manager environment for ${username}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "nix-daemon.socket" ];
|
||||
after = [ "nix-daemon.socket" ];
|
||||
systemd.services = mapAttrs' (_: usercfg:
|
||||
let
|
||||
username = usercfg.home.username;
|
||||
in
|
||||
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
||||
description = "Home Manager environment for ${username}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "nix-daemon.socket" ];
|
||||
after = [ "nix-daemon.socket" ];
|
||||
|
||||
serviceConfig = {
|
||||
User = usercfg.home.username;
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
SyslogIdentifier = "hm-activate-${username}";
|
||||
serviceConfig = {
|
||||
User = usercfg.home.username;
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
SyslogIdentifier = "hm-activate-${username}";
|
||||
|
||||
# The activation script is run by a login shell to make sure
|
||||
# that the user is given a sane Nix environment.
|
||||
ExecStart = pkgs.writeScript "activate-${username}" ''
|
||||
#! ${pkgs.stdenv.shell} -el
|
||||
echo Activating home-manager configuration for ${username}
|
||||
exec ${usercfg.home.activationPackage}/activate
|
||||
'';
|
||||
};
|
||||
}
|
||||
# The activation script is run by a login shell to make sure
|
||||
# that the user is given a sane Nix environment.
|
||||
ExecStart = pkgs.writeScript "activate-${username}" ''
|
||||
#! ${pkgs.stdenv.shell} -el
|
||||
echo Activating home-manager configuration for ${username}
|
||||
exec ${usercfg.home.activationPackage}/activate
|
||||
'';
|
||||
};
|
||||
}
|
||||
) cfg.users;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue