* Support creating non-system user accounts.

svn path=/nixos/trunk/; revision=27545
This commit is contained in:
Eelco Dolstra 2011-06-27 08:50:30 +00:00
parent ab70d480ab
commit 010a2a7555

View file

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