1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

users: create users with home directory /var/empty by default

This commit is contained in:
Michael Hoang 2024-10-28 10:30:02 +11:00
parent c908607e8a
commit f380194f3d
3 changed files with 5 additions and 7 deletions

View file

@ -260,7 +260,7 @@ in
"-UID" v.uid
"-GID" v.gid ]
++ (lib.optionals (v.description != null) [ "-fullName" v.description ])
++ (lib.optionals (v.home != null) [ "-home" v.home ])
++ [ "-home" (if v.home != null then v.home else "/var/empty") ]
++ [ "-shell" (if v.shell != null then shellPath v.shell else "/usr/bin/false") ])} 2> /dev/null
# We need to check as `sysadminctl -addUser` still exits with exit code 0 when there's an error

View file

@ -58,11 +58,9 @@
description = ''
The user's home directory. This defaults to `null`.
When this is set to `null`, the value is managed by macOS instead of
`nix-darwin`. This means if the user has not been created yet,
`sysadminctl` will be called without the `-home` flag which means the
user will have a default home directory of `/Users/<name>` which will
be created by `sysadminctl`.
When this is set to `null`, if the user has not been created yet,
they will be created with the home directory `/var/empty` to match
the old default.
'';
};

View file

@ -51,7 +51,7 @@
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "foo" "-UID" 42000 "-GID" 42000 "-fullName" "Foo user" "-home" "/Users/foo" "-shell" "/run/current-system/sw/bin/bash" ]}" ${config.out}/activate
grep "createhomedir -cu ${lib.escapeShellArg "foo"}" ${config.out}/activate
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "created.user" "-UID" 42001 ]} .* ${lib.escapeShellArgs [ "-shell" "/usr/bin/false" ] }" ${config.out}/activate
(! grep "sysadminctl -addUser ${lib.escapeShellArg "created.user"} .* -home" ${config.out}/activate)
grep "sysadminctl -addUser ${lib.escapeShellArg "created.user"} .* ${lib.escapeShellArgs [ "-home" "/var/empty" ]}" ${config.out}/activate
(! grep "dscl . -delete ${lib.escapeShellArg "/Users/created.user"}" ${config.out}/activate)
(! grep "dscl . -delete ${lib.escapeShellArg "/Groups/created.user"}" ${config.out}/activate)