mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-21 12:59:04 +02:00
* Support creating non-system user accounts.
svn path=/nixos/trunk/; revision=27545
This commit is contained in:
parent
ab70d480ab
commit
010a2a7555
|
@ -24,6 +24,7 @@ let
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# !!! Use NixOS module system to add default attributes.
|
||||||
addAttrs =
|
addAttrs =
|
||||||
{ name
|
{ name
|
||||||
, description
|
, description
|
||||||
|
@ -35,8 +36,9 @@ let
|
||||||
, createHome ? false
|
, createHome ? false
|
||||||
, useDefaultShell ? false
|
, useDefaultShell ? false
|
||||||
, password ? null
|
, password ? null
|
||||||
|
, isSystemUser ? true
|
||||||
}:
|
}:
|
||||||
{ inherit name description uid group extraGroups home shell createHome password; };
|
{ inherit name description uid group extraGroups home shell createHome password isSystemUser; };
|
||||||
|
|
||||||
in map addAttrs (defaultUsers ++ config.users.extraUsers);
|
in map addAttrs (defaultUsers ++ config.users.extraUsers);
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ let
|
||||||
|
|
||||||
# Note: the 'X' in front of the password is to distinguish between
|
# Note: the 'X' in front of the password is to distinguish between
|
||||||
# having an empty password, and not having a password.
|
# having an empty password, and not having a password.
|
||||||
serializedUser = u: "${u.name}\n${u.description}\n${toString u.uid}\n${u.group}\n${toString (concatStringsSep "," u.extraGroups)}\n${u.home}\n${u.shell}\n${toString u.createHome}\n${if u.password != null then "X" + u.password else ""}\n";
|
serializedUser = u: "${u.name}\n${u.description}\n${toString u.uid}\n${u.group}\n${toString (concatStringsSep "," u.extraGroups)}\n${u.home}\n${u.shell}\n${toString u.createHome}\n${if u.password != null then "X" + u.password else ""}\n${toString u.isSystemUser}\n";
|
||||||
serializedGroup = g: "${g.name}\n${toString g.gid}";
|
serializedGroup = g: "${g.name}\n${toString g.gid}";
|
||||||
|
|
||||||
# keep this extra file so that cat can be used to pass special chars such as "`" which is used in the avahi daemon
|
# keep this extra file so that cat can be used to pass special chars such as "`" which is used in the avahi daemon
|
||||||
|
@ -186,9 +188,10 @@ in
|
||||||
read shell
|
read shell
|
||||||
read createHome
|
read createHome
|
||||||
read password
|
read password
|
||||||
|
read isSystemUser
|
||||||
|
|
||||||
if ! curEnt=$(getent passwd "$name"); then
|
if ! curEnt=$(getent passwd "$name"); then
|
||||||
useradd --system \
|
useradd ''${isSystemUser:+--system} \
|
||||||
--comment "$description" \
|
--comment "$description" \
|
||||||
''${uid:+--uid $uid} \
|
''${uid:+--uid $uid} \
|
||||||
--gid "$group" \
|
--gid "$group" \
|
||||||
|
|
Loading…
Reference in a new issue