summaryrefslogtreecommitdiff
path: root/modules/users
diff options
context:
space:
mode:
authorHraban Luyat <hraban@0brg.net>2023-11-23 14:54:06 -0500
committerHraban Luyat <hraban@0brg.net>2024-01-20 11:03:15 -0500
commit888533c35fb0b46a8b537528b9990ab838ee3efc (patch)
tree4d17edd8080ff2e89577a48170b0b1391afd82f7 /modules/users
parent74ab0227ee495e526f2dd57ea684b34f6396445a (diff)
fix: user shell path handling
Properly detect the binary name (not just /nix/store/...-bash, but include the .../bin/bash), and use the symlinked name which also appears in /etc/shells.
Diffstat (limited to 'modules/users')
-rw-r--r--modules/users/default.nix12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/users/default.nix b/modules/users/default.nix
index 5712002..1c74840 100644
--- a/modules/users/default.nix
+++ b/modules/users/default.nix
@@ -24,6 +24,14 @@ let
deletedUsers = filter (n: isDeleted cfg.users n) cfg.knownUsers;
packageUsers = filterAttrs (_: u: u.packages != []) cfg.users;
+
+ # convert a valid argument to user.shell into a string that points to a shell
+ # executable. Logic copied from modules/system/shells.nix.
+ shellPath = v:
+ if types.shellPackage.check v
+ then "/run/current-system/sw${v.shellPath}"
+ else v;
+
in
{
@@ -158,12 +166,14 @@ in
dscl . -create '/Users/${v.name}' IsHidden ${if v.isHidden then "1" else "0"}
dscl . -create '/Users/${v.name}' RealName '${v.description}'
dscl . -create '/Users/${v.name}' NFSHomeDirectory '${v.home}'
- dscl . -create '/Users/${v.name}' UserShell '${v.shell}'
${optionalString v.createHome "createhomedir -cu '${v.name}'"}
else
if [ "$u" -ne ${toString v.uid} ]; then
echo "warning: existing user '${v.name}' has unexpected uid $u, skipping..." >&2
fi
+
+ # Always set the shell path, in case it was updated
+ dscl . -create '/Users/${v.name}' UserShell ${lib.escapeShellArg (shellPath v.shell)}
fi
'') createdUsers}