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

Merge pull request #128 from kalbasit/nix-darwin_create-user-directory

users: create the home directory when creating a new user
This commit is contained in:
Daiderd Jordan 2019-02-24 22:15:06 +01:00 committed by GitHub
commit 944d217c3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View file

@ -139,6 +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.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