fix(install): pin HOME=/root so root nix never strays into /home/nomarchy
`exec sudo --preserve-env` (needed to carry the NOMARCHY_* vars) also drags the live session user's HOME=/home/nomarchy into the root install process. Root-run `nix build` then writes an eval cache + .nix-defexpr there, and the in-chroot one lands on the TARGET as a stray, orphaned /home/nomarchy (no such user on the installed system). Pin root's own HOME after the sudo re-exec, and again inside the nixos-enter chroot script. The user activation already sets HOME=/home/$USERNAME and is unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,15 @@ if [[ $EUID -ne 0 ]]; then
|
|||||||
exec sudo --preserve-env "$0" "$@"
|
exec sudo --preserve-env "$0" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# `sudo --preserve-env` (needed to carry the NOMARCHY_* vars) also drags in
|
||||||
|
# the live session user's HOME=/home/nomarchy. Root-run `nix` calls below
|
||||||
|
# would then scribble an eval cache + .nix-defexpr into /home/nomarchy —
|
||||||
|
# and the in-chroot one lands on the TARGET disk as a stray, orphaned
|
||||||
|
# /home/nomarchy (no such user on the installed system). Pin root's own
|
||||||
|
# HOME so every root nix invocation stays in /root; the user activation
|
||||||
|
# sets HOME=/home/$USERNAME explicitly and is unaffected.
|
||||||
|
export HOME=/root
|
||||||
|
|
||||||
header "Nomarchy installer" "NixOS, themed and ready to go."
|
header "Nomarchy installer" "NixOS, themed and ready to go."
|
||||||
|
|
||||||
[[ -d /sys/firmware/efi ]] \
|
[[ -d /sys/firmware/efi ]] \
|
||||||
@@ -628,6 +637,8 @@ cat > /mnt/root/nomarchy-hm-activate.sh <<EOF
|
|||||||
set -ex
|
set -ex
|
||||||
exec > /var/log/nomarchy-hm-preactivate.log 2>&1
|
exec > /var/log/nomarchy-hm-preactivate.log 2>&1
|
||||||
export PATH=/run/current-system/sw/bin:\$PATH
|
export PATH=/run/current-system/sw/bin:\$PATH
|
||||||
|
# Keep root's nix state in /root, not a stray /home/nomarchy on the target.
|
||||||
|
export HOME=/root
|
||||||
# Normally pre-built in the live env and copied over; the in-chroot
|
# Normally pre-built in the live env and copied over; the in-chroot
|
||||||
# build (default substituters — the live-side build already proved the
|
# build (default substituters — the live-side build already proved the
|
||||||
# no-network case) is a last-resort fallback.
|
# no-network case) is a last-resort fallback.
|
||||||
|
|||||||
Reference in New Issue
Block a user