diff --git a/pkgs/nomarchy-install/nomarchy-install.sh b/pkgs/nomarchy-install/nomarchy-install.sh index b7ed0a6..8bdc79f 100644 --- a/pkgs/nomarchy-install/nomarchy-install.sh +++ b/pkgs/nomarchy-install/nomarchy-install.sh @@ -496,13 +496,9 @@ 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" # The templates come out of the nix store mode 0444 and cp preserves -# that — without this the user owns home.nix but can't edit it. +# that — without this the user can't edit home.nix after they own it. +# Ownership is applied after nixos-install (real uid/gid; see below). chmod -R u+w "$FLAKE_DIR" # /etc/nixos on the installed system points at the user-owned flake. @@ -554,6 +550,17 @@ fi nixos-install --no-root-passwd "${NIXOS_INSTALL_OPTS[@]}" --flake "path:$FLAKE_DIR#default" success "System installed (bootloader in place)" +# The user must own their flake — libgit2 refuses repositories owned by +# someone else, which breaks `home-manager switch` (and theme switching) +# outright. Resolve real uid/gid from the target after nixos-install +# created the account (do not hard-code 1000:100 — first free uid or +# primary group can differ). +USER_UID=$(nixos-enter --root /mnt -- id -u "$USERNAME") \ + || fail "Could not resolve uid for install user '$USERNAME' on target" +USER_GID=$(nixos-enter --root /mnt -- id -g "$USERNAME") \ + || fail "Could not resolve gid for install user '$USERNAME' on target" +chown -R "$USER_UID:$USER_GID" "$FLAKE_DIR" + # Pre-activate the Home Manager generation so the FIRST boot lands in the # fully themed desktop, not bare Hyprland. Best-effort: a failure here # only costs the user one `home-manager switch` after logging in. @@ -629,8 +636,8 @@ else tail -n 5 /mnt/var/log/nomarchy-hm-preactivate.log 2>/dev/null || true # The live session (and this warning) ends with this install — drop a # durable hint on the TARGET so the fix still surfaces on first login. - # Numeric ids: the account doesn't exist in the live environment yet - # (same reasoning as the $FLAKE_DIR chown above). + # Numeric ids from the target account (USER_UID/USER_GID above) — the + # name does not exist in the live ISO's passwd. hint_file="/mnt/home/$USERNAME/NOMARCHY-DESKTOP-NOT-THEMED.txt" cat > "$hint_file" <