1
0
Fork 0
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:
Wael M. Nasreddine 2019-02-23 08:29:57 -08:00 committed by Daiderd Jordan
parent 7c68f69154
commit 41a00f14b4
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 9 additions and 4 deletions

View file

@ -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 "warning: existing user '${v.name}' has unexpected uid $u, skipping..." >&2

View file

@ -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";

View file

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