mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
users: gate the creation with an option, false by default and use createhomedir
This commit is contained in:
parent
7c68f69154
commit
41a00f14b4
3 changed files with 9 additions and 4 deletions
|
@ -139,10 +139,7 @@ in
|
|||
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.home != "/var/empty") ''
|
||||
mkdir -p '${v.home}'
|
||||
chown '${toString v.uid}:${toString v.gid}' '${v.home}'
|
||||
''}
|
||||
${optionalString v.createHome "createhomedir -cu '${v.name}'"}
|
||||
else
|
||||
if [ "$u" -ne ${toString v.uid} ]; then
|
||||
echo "[1;31mwarning: existing user '${v.name}' has unexpected uid $u, skipping...[0m" >&2
|
||||
|
|
|
@ -51,6 +51,12 @@ with lib;
|
|||
description = "The user's home directory.";
|
||||
};
|
||||
|
||||
createHome = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Create the home directory when creating the user.";
|
||||
};
|
||||
|
||||
shell = mkOption {
|
||||
type = types.either types.shellPackage types.path;
|
||||
default = "/sbin/nologin";
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
users.users.foo.description = "Foo user";
|
||||
users.users.foo.isHidden = false;
|
||||
users.users.foo.home = "/Users/foo";
|
||||
users.users.foo.createHome = true;
|
||||
users.users.foo.shell = "/run/current-system/sw/bin/bash";
|
||||
|
||||
users.users."created.user".uid = 42001;
|
||||
|
@ -47,6 +48,7 @@
|
|||
grep "dscl . -create '/Users/foo' NFSHomeDirectory '/Users/foo'" ${config.out}/activate
|
||||
grep "dscl . -create '/Users/foo' UserShell '/run/current-system/sw/bin/bash'" ${config.out}/activate
|
||||
grep "dscl . -create '/Users/created.user' UniqueID 42001" ${config.out}/activate
|
||||
grep "createhomedir -cu 'foo'" ${config.out}/activate
|
||||
grep -qv "dscl . -delete '/Groups/created.user'" ${config.out}/activate
|
||||
|
||||
echo "checking user deletion in /activate" >&2
|
||||
|
|
Loading…
Reference in a new issue