From 59dc10b5a6f2a592af36375c68fda41246794b86 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 5 Dec 2023 13:20:36 +0100 Subject: 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 = {}; --- nixos/modules/config/users-groups.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index 39aac9fb821bd..2aed620eb154c 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -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; -- cgit 1.4.1