Commit 59dc10b5 authored by Alyssa Ross's avatar Alyssa Ross
Browse files

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 = {};
parent 9bcf41fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;