summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/users/default.nix9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/users/default.nix b/modules/users/default.nix
index f57dfa5..08785be 100644
--- a/modules/users/default.nix
+++ b/modules/users/default.nix
@@ -149,19 +149,20 @@ in
echo "setting up users..." >&2
${concatMapStringsSep "\n" (v: let
+ name = lib.escapeShellArg v.name;
dsclUser = lib.escapeShellArg "/Users/${v.name}";
in ''
${optionalString cfg.forceRecreate ''
- u=$(id -u ${lib.escapeShellArg v.name} 2> /dev/null) || true
+ u=$(id -u ${name} 2> /dev/null) || true
if [[ "$u" -eq ${toString v.uid} ]]; then
echo "deleting user ${v.name}..." >&2
- sysadminctl -deleteUser ${lib.escapeShellArg v.name} 2> /dev/null
+ sysadminctl -deleteUser ${name} 2> /dev/null
else
echo "warning: existing user '${v.name}' has unexpected uid $u, skipping..." >&2
fi
''}
- u=$(id -u ${lib.escapeShellArg v.name} 2> /dev/null) || true
+ u=$(id -u ${name} 2> /dev/null) || true
if [[ -n "$u" && "$u" -ne "${toString v.uid}" ]]; then
echo "warning: existing user '${v.name}' has unexpected uid $u, skipping..." >&2
else
@@ -169,7 +170,7 @@ in
echo "creating user ${v.name}..." >&2
sysadminctl -addUser ${lib.escapeShellArgs [ v.name "-UID" v.uid "-GID" v.gid "-fullName" v.description "-home" v.home "-shell" (shellPath v.shell) ]}
dscl . -create ${dsclUser} IsHidden ${if v.isHidden then "1" else "0"}
- ${optionalString v.createHome "createhomedir -cu '${v.name}'"}
+ ${optionalString v.createHome "createhomedir -cu ${name}"}
fi
# Always set the shell path, in case it was updated
dscl . -create ${dsclUser} UserShell ${lib.escapeShellArg (shellPath v.shell)}