From 995810927dd8932755430f8a936e5560ee2e2f72 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Sat, 20 Jun 2026 18:23:21 +0100 Subject: [PATCH] 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 --- pkgs/nomarchy-install/nomarchy-install.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/nomarchy-install/nomarchy-install.sh b/pkgs/nomarchy-install/nomarchy-install.sh index 7ad186a..83f96de 100644 --- a/pkgs/nomarchy-install/nomarchy-install.sh +++ b/pkgs/nomarchy-install/nomarchy-install.sh @@ -54,6 +54,15 @@ if [[ $EUID -ne 0 ]]; then exec sudo --preserve-env "$0" "$@" 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." [[ -d /sys/firmware/efi ]] \ @@ -628,6 +637,8 @@ cat > /mnt/root/nomarchy-hm-activate.sh < /var/log/nomarchy-hm-preactivate.log 2>&1 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 # build (default substituters — the live-side build already proved the # no-network case) is a last-resort fallback.