From e0e65cbf8e4ce940c67b5d0fb0d349758230119e Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 29 Aug 2014 07:17:19 +0200 Subject: [PATCH] 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 --- nixos/modules/config/users-groups.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index f1ddd377ed01..a55593c2bad8 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -309,19 +309,19 @@ let 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)); groupFile = pkgs.writeText "group" ( concatStringsSep "\n" (map (g: mkGroupEntry g.name) ( - let f = g: g.gid != null; in - sortOn "gid" (filter f (attrValues cfg.extraGroups)) + sortOn "gid" (filterNull "gid" (attrValues cfg.extraGroups)) )) ); passwdFile = pkgs.writeText "passwd" ( concatStringsSep "\n" (map (u: mkPasswdEntry u.name) ( - let f = u: u.createUser && (u.uid != null); in - sortOn "uid" (filter f (attrValues cfg.extraUsers)) + sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers)) )) ); @@ -330,14 +330,14 @@ let user.subUidRanges); subuidFile = concatStrings (map mkSubuidEntry ( - sortOn "uid" (attrValues cfg.extraUsers))); + sortOn "uid" (filterNull "uid" (attrValues cfg.extraUsers)))); mkSubgidEntry = user: concatStrings ( map (range: "${user.name}:${toString range.startGid}:${toString range.count}\n") user.subGidRanges); 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 # users.extra{Users,Groups} to /etc/{passwd,group} iff there isn't any