fix(install): chown flake dir with real install-user uid/gid (#65)
Hard-coded 1000:100 assumed the first free normal uid and users(100). After nixos-install, resolve id -u/-g for USERNAME on the target and chown FLAKE_DIR (and the HM-fail hint file) to those ids.
This commit is contained in:
@@ -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" <<HINT
|
||||
Desktop pre-activation failed during install — see
|
||||
@@ -640,7 +647,7 @@ Desktop pre-activation failed during install — see
|
||||
|
||||
(delete this file once done)
|
||||
HINT
|
||||
chown 1000:100 "$hint_file"
|
||||
chown "$USER_UID:$USER_GID" "$hint_file"
|
||||
fi
|
||||
rm -f /mnt/root/nomarchy-hm-activate.sh
|
||||
|
||||
|
||||
Reference in New Issue
Block a user