mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-13 20:41:07 +01:00
home-environment: add home.uid option
Add a home.uid option similar to home.username. When set, the activation script verifies the current UID matches the expected value using the new checkUid function. When using the NixOS or nix-darwin modules, home.uid is auto-discovered from users.users.<name>.uid when that value is set. This is useful for constructing paths that depend on the user's UID, such as /run/user/<uid> paths for gpg-agent sockets or other user-specific runtime directories.
This commit is contained in:
parent
d441981b20
commit
a521eab881
6 changed files with 38 additions and 0 deletions
|
|
@ -3,4 +3,6 @@
|
|||
home-session-search-variables = ./session-search-variables.nix;
|
||||
home-session-variables = ./session-variables.nix;
|
||||
home-nixpkgs-release-check-pkgs = ./nixpkgs-release-check-pkgs.nix;
|
||||
home-uid = ./uid.nix;
|
||||
home-uid-null = ./uid-null.nix;
|
||||
}
|
||||
|
|
|
|||
7
tests/modules/home-environment/uid-null.nix
Normal file
7
tests/modules/home-environment/uid-null.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
# home.uid defaults to null, so checkUid should not be called in the activation script
|
||||
|
||||
nmt.script = ''
|
||||
assertFileNotRegex activate "checkUid [0-9]+"
|
||||
'';
|
||||
}
|
||||
7
tests/modules/home-environment/uid.nix
Normal file
7
tests/modules/home-environment/uid.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
home.uid = 1000;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains activate "checkUid 1000"
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue