aboutsummaryrefslogtreecommitdiff
path: root/nixos
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2019-05-24 09:17:25 +0200
committerRobert Helgesson <robert@rycee.net>2019-05-25 14:26:49 +0200
commit2e13c3cdfdb86e0d7dc0dd7a690db417714e4334 (patch)
tree5d8b027ca91cc605dfd77c302b765a41db204a79 /nixos
parentd726afd9e45246fe68cfff0af80600ea26bd79fe (diff)
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.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/default.nix43
1 files changed, 23 insertions, 20 deletions
diff --git a/nixos/default.nix b/nixos/default.nix
index 5328e578124..4628d1f2d9f 100644
--- a/nixos/default.nix
+++ b/nixos/default.nix
@@ -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;
};
}