1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-08-17 00:20:44 +03:00

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.
This commit is contained in:
Hraban Luyat 2023-11-23 14:54:06 -05:00
parent 74ab0227ee
commit 888533c35f

View File

@ -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}