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:
commit
944d217c3a
3 changed files with 9 additions and 0 deletions
|
@ -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 "[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