Skip to content

Commit 03b6a55

Browse files
nixos/users-groups: split isSystemUser/isNormalUser and uid check into two (#357944)
2 parents 47f9226 + db0a0b1 commit 03b6a55

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

nixos/modules/config/users-groups.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,18 @@ in {
940940
of /etc/shadow (file where hashes are stored) are colon-separated.
941941
Please check the value of option `users.users."${user.name}".hashedPassword`.'';
942942
}
943+
{
944+
assertion = user.isNormalUser && user.uid != null -> user.uid >= 1000;
945+
message = ''
946+
A user cannot have a users.users.${user.name}.uid set below 1000 and set users.users.${user.name}.isNormalUser.
947+
Either users.users.${user.name}.isSystemUser must be set to true instead of users.users.${user.name}.isNormalUser
948+
or users.users.${user.name}.uid must be changed to 1000 or above.
949+
'';
950+
}
943951
{
944952
assertion = let
945-
isEffectivelySystemUser = user.isSystemUser || (user.uid != null && user.uid < 1000);
953+
# we do an extra check on isNormalUser here, to not trigger this assertion when isNormalUser is set and uid to < 1000
954+
isEffectivelySystemUser = user.isSystemUser || (user.uid != null && user.uid < 1000 && !user.isNormalUser);
946955
in xor isEffectivelySystemUser user.isNormalUser;
947956
message = ''
948957
Exactly one of users.users.${user.name}.isSystemUser and users.users.${user.name}.isNormalUser must be set.

0 commit comments

Comments
 (0)