mirror of
https://github.com/nix-community/home-manager
synced 2024-12-03 08:29:46 +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.
(cherry picked from commit 2e13c3cdfd
)
This commit is contained in:
parent
41d2a16f99
commit
3daa1da497
1 changed files with 23 additions and 20 deletions
|
@ -60,28 +60,31 @@ in
|
||||||
}) cfg.users
|
}) cfg.users
|
||||||
);
|
);
|
||||||
|
|
||||||
systemd.services = mapAttrs' (username: usercfg:
|
systemd.services = mapAttrs' (_: usercfg:
|
||||||
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
let
|
||||||
description = "Home Manager environment for ${username}";
|
username = usercfg.home.username;
|
||||||
wantedBy = [ "multi-user.target" ];
|
in
|
||||||
wants = [ "nix-daemon.socket" ];
|
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
||||||
after = [ "nix-daemon.socket" ];
|
description = "Home Manager environment for ${username}";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
wants = [ "nix-daemon.socket" ];
|
||||||
|
after = [ "nix-daemon.socket" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = usercfg.home.username;
|
User = usercfg.home.username;
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = "yes";
|
RemainAfterExit = "yes";
|
||||||
SyslogIdentifier = "hm-activate-${username}";
|
SyslogIdentifier = "hm-activate-${username}";
|
||||||
|
|
||||||
# The activation script is run by a login shell to make sure
|
# The activation script is run by a login shell to make sure
|
||||||
# that the user is given a sane Nix environment.
|
# that the user is given a sane Nix environment.
|
||||||
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.activationPackage}/activate
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
) cfg.users;
|
) cfg.users;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue