1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00

nixos/users-groups: fix confusing error message

If we include users with unset groups, we get this very confusing
message, with invalid Nix code:

       - The following users have a primary group that is undefined: qyliss
       Hint: Add this to your NixOS configuration:
         users.groups. = {};

We don't need to include such users in this check, since they'll be
caught anyway by this one:

       - users.users.qyliss.group is unset. This used to default to
       nogroup, but this is unsafe. For example you can create a group
       for this user with:
       users.users.qyliss.group = "qyliss";
       users.groups.qyliss = {};
This commit is contained in:
Alyssa Ross 2023-12-05 13:20:36 +01:00
parent 9bcf41fe0d
commit 59dc10b5a6

View file

@ -475,7 +475,7 @@ let
sdInitrdUidsAreUnique = idsAreUnique (filterAttrs (n: u: u.uid != null) config.boot.initrd.systemd.users) "uid";
sdInitrdGidsAreUnique = idsAreUnique (filterAttrs (n: g: g.gid != null) config.boot.initrd.systemd.groups) "gid";
groupNames = lib.mapAttrsToList (n: g: g.name) cfg.groups;
usersWithoutExistingGroup = lib.filterAttrs (n: u: !lib.elem u.group groupNames) cfg.users;
usersWithoutExistingGroup = lib.filterAttrs (n: u: u.group != "" && !lib.elem u.group groupNames) cfg.users;
spec = pkgs.writeText "users-groups.json" (builtins.toJSON {
inherit (cfg) mutableUsers;