nixos/users-groups: Fix eval on missing uid/gid.
This hopefully fixes a regression introduced by 08b214a. In bf129a2, it was already fixed for normal uid/gid values and it got reintroduced by sub-uid/gid-handling again, so I've refactored it a bit into a filterNull function which takes care of also the filtering introduced by bf129a2. I have not tested this extensively, but master is already broken for systems with `mutableUsers = true` and no uid values set. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
fe287a2601
commit
e0e65cbf8e
@ -309,19 +309,19 @@ let
|
|||||||
u.description u.home u.shell
|
u.description u.home u.shell
|
||||||
];
|
];
|
||||||
|
|
||||||
|
filterNull = a: filter (x: hasAttr a x && getAttr a x != null);
|
||||||
|
|
||||||
sortOn = a: sort (as1: as2: lessThan (getAttr a as1) (getAttr a as2));
|
sortOn = a: sort (as1: as2: lessThan (getAttr a as1) (getAttr a as2));
|
||||||
|
|
||||||
groupFile = pkgs.writeText "group" (
|
groupFile = pkgs.writeText "group" (
|
||||||
concatStringsSep "\n" (map (g: mkGroupEntry g.name) (
|
concatStringsSep "\n" (map (g: mkGroupEntry g.name) (
|
||||||
let f = g: g.gid != null; in
|
sortOn "gid" (filterNull "gid" (attrValues cfg.extraGroups))
|
||||||
sortOn "gid" (filter f (attrValues cfg.extraGroups))
|
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
passwdFile = pkgs.writeText "passwd" (
|
passwdFile = pkgs.writeText "passwd" (
|
||||||
concatStringsSep "\n" (map (u: mkPasswdEntry u.name) (
|
concatStringsSep "\n" (map (u: mkPasswdEntry u.name) (
|
||||||
let f = u: u.createUser && (u.uid != null); in
|
sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers))
|
||||||
sortOn "uid" (filter f (attrValues cfg.extraUsers))
|
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -330,14 +330,14 @@ let
|
|||||||
user.subUidRanges);
|
user.subUidRanges);
|
||||||
|
|
||||||
subuidFile = concatStrings (map mkSubuidEntry (
|
subuidFile = concatStrings (map mkSubuidEntry (
|
||||||
sortOn "uid" (attrValues cfg.extraUsers)));
|
sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers))));
|
||||||
|
|
||||||
mkSubgidEntry = user: concatStrings (
|
mkSubgidEntry = user: concatStrings (
|
||||||
map (range: "${user.name}:${toString range.startGid}:${toString range.count}\n")
|
map (range: "${user.name}:${toString range.startGid}:${toString range.count}\n")
|
||||||
user.subGidRanges);
|
user.subGidRanges);
|
||||||
|
|
||||||
subgidFile = concatStrings (map mkSubgidEntry (
|
subgidFile = concatStrings (map mkSubgidEntry (
|
||||||
sortOn "uid" (attrValues cfg.extraUsers)));
|
sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers))));
|
||||||
|
|
||||||
# If mutableUsers is true, this script adds all users/groups defined in
|
# If mutableUsers is true, this script adds all users/groups defined in
|
||||||
# users.extra{Users,Groups} to /etc/{passwd,group} iff there isn't any
|
# users.extra{Users,Groups} to /etc/{passwd,group} iff there isn't any
|
||||||
|
Loading…
x
Reference in New Issue
Block a user