Bring back the isSystemUser option

This commit is contained in:
Eelco Dolstra 2014-04-29 10:43:38 +02:00
parent 2dfbe55421
commit 05468f9b78

View File

@ -55,13 +55,27 @@ let
type = with types; nullOr int; type = with types; nullOr int;
default = null; default = null;
description = '' description = ''
The account UID. If the <literal>mutableUsers</literal> option The account UID. If the <option>mutableUsers</option> option
is false, the UID cannot be null. Otherwise, the UID might be is false, the UID cannot be null. Otherwise, the UID might be
null, in which case a free UID is picked on activation (by the null, in which case a free UID is picked on activation (by the
useradd command). useradd command).
''; '';
}; };
isSystemUser = mkOption {
type = types.bool;
default = false;
description = ''
Indicates if the user is a system user or not. This option
only has an effect if <option>mutableUsers</option> is
<literal>true</literal> and <option>uid</option> is
<option>null</option>, in which case it determines whether
the user's UID is allocated in the range for system users
(below 500) or in the range for normal users (starting at
1000).
'';
};
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = "nogroup"; default = "nogroup";
@ -459,17 +473,16 @@ in {
''; '';
groupadd = n: g: '' groupadd = n: g: ''
if [ -z "$(getent group "${g.name}")" ]; then if [ -z "$(getent group "${g.name}")" ]; then
echo "Adding group ${g.name}"
${pkgs.shadow}/sbin/groupadd "${g.name}" ${pkgs.shadow}/sbin/groupadd "${g.name}"
fi fi
''; '';
useradd = n: u: '' useradd = n: u: ''
if ! id "${u.name}" &>/dev/null; then if ! id "${u.name}" &>/dev/null; then
echo "Adding user ${u.name}"
${pkgs.shadow}/sbin/useradd \ ${pkgs.shadow}/sbin/useradd \
-g "${u.group}" \ -g "${u.group}" \
-s "${u.shell}" \ -s "${u.shell}" \
-d "${u.home}" \ -d "${u.home}" \
${optionalString u.isSystemUser "--system"} \
"${u.name}" "${u.name}"
echo "${u.name}:x" | ${pkgs.shadow}/sbin/chpasswd -e echo "${u.name}:x" | ${pkgs.shadow}/sbin/chpasswd -e
fi fi