From 1403ea82b260e51d9f311ac57a5b125dc7a22fbf Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Thu, 11 Jun 2026 11:17:38 +0100 Subject: [PATCH] fix(install): chown the generated flake to the user; harden HM pre-activation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit End-to-end VM verification found the installed system perfect (LUKS, auto-login, swapfile+resume, snapper) except: ~/.nomarchy was root-owned, so libgit2 refused every `home-manager switch` ("repository not owned by current user"). chown 1000:users after generation (the account doesn't exist in the target yet — numeric ids). The chroot pre-activation now builds via path: instead of git+file — no libgit2, no ownership sensitivity — and the fallback message suggests -b bak (a default-config Hyprland session leaves an autogenerated hyprland.conf in the way otherwise; observed live). Co-Authored-By: Claude Fable 5 --- pkgs/nomarchy-install/nomarchy-install.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/nomarchy-install/nomarchy-install.sh b/pkgs/nomarchy-install/nomarchy-install.sh index e957b97..4b7f8c8 100644 --- a/pkgs/nomarchy-install/nomarchy-install.sh +++ b/pkgs/nomarchy-install/nomarchy-install.sh @@ -405,6 +405,12 @@ fi commit -qm "Initial Nomarchy configuration" ) +# The user must own their flake — libgit2 refuses repositories owned by +# someone else, which breaks `home-manager switch` (and theme switching) +# outright. The first normal NixOS user is always 1000:users(100); the +# account doesn't exist in the target yet, so numeric ids it is. +chown -R 1000:100 "$FLAKE_DIR" + # /etc/nixos on the installed system points at the user-owned flake. mkdir -p /mnt/etc ln -sfn "/home/$USERNAME/.nomarchy" /mnt/etc/nixos @@ -463,7 +469,7 @@ export NIX_CONFIG=$(printf '%q' "$NIX_CONFIG") out=\$(nix --extra-experimental-features "nix-command flakes" \ build --no-link --print-out-paths \ --option substituters "" \ - "/home/$USERNAME/.nomarchy#homeConfigurations.$USERNAME.activationPackage") + "path:/home/$USERNAME/.nomarchy#homeConfigurations.$USERNAME.activationPackage") install -d -o "$USERNAME" -g users /nix/var/nix/profiles/per-user/$USERNAME install -d -o "$USERNAME" -g users /nix/var/nix/gcroots/per-user/$USERNAME runuser -u "$USERNAME" -- bash -lc "USER=$USERNAME HOME=/home/$USERNAME \$out/activate" @@ -472,7 +478,7 @@ if nixos-enter --root /mnt -- bash /tmp/nomarchy-hm-activate.sh; then success "Desktop pre-activated — first boot is fully themed" else warn "Desktop pre-activation failed; after first login run:" - warn " home-manager switch --flake ~/.nomarchy" + warn " home-manager switch --flake ~/.nomarchy -b bak" fi rm -f /mnt/tmp/nomarchy-hm-activate.sh