Skip to content

Commit 71cdb94

Browse files
committed
home-environment: require home.uid for stateVersion >= 26.05
Make home.uid mandatory for users with stateVersion 26.05 or later. This follows up on the addition of home.uid in a521eab, addressing the discussion about making the option required. When using Home Manager as a NixOS or nix-darwin module, home.uid is automatically set from users.users.<name>.uid when that option is defined. For standalone usage or when the system user has no explicit UID, users must now set home.uid directly.
1 parent 9379fbf commit 71cdb94

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

docs/release-notes/rl-2605.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ changes are only active if the `home.stateVersion` option is set to
1515

1616
- The `gtk.gtk4.theme` option does not mirror `gtk.theme` by default
1717
anymore.
18+
19+
- The `home.uid` option is now required. When using Home Manager as a
20+
NixOS or nix-darwin module, this is automatically set from
21+
`users.users.<name>.uid` if that option is defined. For standalone
22+
usage or when the system user has no explicit UID, set `home.uid`
23+
to your user's UID (run `id -u` to find it).

modules/home-environment.nix

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ in
197197
type = types.nullOr types.ints.unsigned;
198198
default = null;
199199
example = 1000;
200-
description = "The user's uid.";
200+
description = ''
201+
The user's UID. Required for state version 26.05 and later.
202+
203+
When using Home Manager as a NixOS or nix-darwin module, this value
204+
is automatically set from {option}`users.users.<name>.uid` when that
205+
option is defined.
206+
'';
201207
};
202208

203209
home.homeDirectory = mkOption {
@@ -572,6 +578,16 @@ in
572578
assertion = config.home.homeDirectory != "";
573579
message = "Home directory could not be determined";
574580
}
581+
{
582+
assertion = lib.versionOlder config.home.stateVersion "26.05" || config.home.uid != null;
583+
message = ''
584+
User ID (UID) could not be determined. Please set 'home.uid' to your
585+
user's UID. You can find your UID by running 'id -u' in your terminal.
586+
587+
If you are using Home Manager as a NixOS or nix-darwin module, you can
588+
alternatively set 'users.users.<name>.uid' in your system configuration.
589+
'';
590+
}
575591
];
576592

577593
warnings =
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ config, lib, ... }:
2+
3+
{
4+
time = "2025-12-04T18:39:36+00:00";
5+
condition = lib.versionAtLeast config.home.stateVersion "26.05";
6+
message = ''
7+
The 'home.uid' option is now required for state version 26.05 and later.
8+
9+
When using Home Manager as a NixOS or nix-darwin module, this value is
10+
automatically set from 'users.users.<name>.uid' when that option is defined.
11+
12+
For standalone usage, or when the system user has no explicit UID, add to
13+
your configuration:
14+
15+
home.uid = 1000; # Replace with your actual UID (run 'id -u')
16+
'';
17+
}

tests/modules/home-environment/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
home-nixpkgs-release-check-pkgs = ./nixpkgs-release-check-pkgs.nix;
66
home-uid = ./uid.nix;
77
home-uid-null = ./uid-null.nix;
8+
home-uid-required = ./uid-required.nix;
89
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
home.stateVersion = "26.05";
3+
# home.uid defaults to null, which should trigger assertion for 26.05+
4+
5+
test.asserts.assertions.expected = [
6+
''
7+
User ID (UID) could not be determined. Please set 'home.uid' to your
8+
user's UID. You can find your UID by running 'id -u' in your terminal.
9+
10+
If you are using Home Manager as a NixOS or nix-darwin module, you can
11+
alternatively set 'users.users.<name>.uid' in your system configuration.
12+
''
13+
];
14+
}

0 commit comments

Comments
 (0)