1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-15 17:51:01 +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}' RealName '${v.description}'
dscl . -create '/Users/${v.name}' NFSHomeDirectory '${v.home}' dscl . -create '/Users/${v.name}' NFSHomeDirectory '${v.home}'
dscl . -create '/Users/${v.name}' UserShell '${v.shell}' dscl . -create '/Users/${v.name}' UserShell '${v.shell}'
${optionalString v.createHome "createhomedir -cu '${v.name}'"}
else else
if [ "$u" -ne ${toString v.uid} ]; then if [ "$u" -ne ${toString v.uid} ]; then
echo "warning: existing user '${v.name}' has unexpected uid $u, skipping..." >&2 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."; description = "The user's home directory.";
}; };
createHome = mkOption {
type = types.bool;
default = false;
description = "Create the home directory when creating the user.";
};
shell = mkOption { shell = mkOption {
type = types.either types.shellPackage types.path; type = types.either types.shellPackage types.path;
default = "/sbin/nologin"; default = "/sbin/nologin";

View file

@ -15,6 +15,7 @@
users.users.foo.description = "Foo user"; users.users.foo.description = "Foo user";
users.users.foo.isHidden = false; users.users.foo.isHidden = false;
users.users.foo.home = "/Users/foo"; users.users.foo.home = "/Users/foo";
users.users.foo.createHome = true;
users.users.foo.shell = "/run/current-system/sw/bin/bash"; users.users.foo.shell = "/run/current-system/sw/bin/bash";
users.users."created.user".uid = 42001; 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' 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/foo' UserShell '/run/current-system/sw/bin/bash'" ${config.out}/activate
grep "dscl . -create '/Users/created.user' UniqueID 42001" ${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 grep -qv "dscl . -delete '/Groups/created.user'" ${config.out}/activate
echo "checking user deletion in /activate" >&2 echo "checking user deletion in /activate" >&2