mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-08 18:11:05 +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
|
|
@ -117,6 +117,17 @@ function checkHomeDirectory() {
|
|||
fi
|
||||
}
|
||||
|
||||
function checkUid() {
|
||||
local expectedUid="$1"
|
||||
local actualUid
|
||||
actualUid="$(id -u)"
|
||||
|
||||
if [[ "$actualUid" != "$expectedUid" ]]; then
|
||||
_iError 'Error: UID is "%s" but we expect "%s"' "$actualUid" "$expectedUid"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Note, the VERBOSE_ECHO variable is deprecated and should not be used inside
|
||||
# the Home Manager project. It is provided here for backwards compatibility.
|
||||
if [[ -v VERBOSE ]]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue