fix(installer): repair git init, LUKS reprompt, impermanence-no exit, quiet disko

- nrun git git init -q passed 'git' as a subcommand to git itself,
  failing the post-disko repo init. Drop the duplicated arg.
- disko's luks module reads passwordFile at the top level; placing it
  under settings.* meant it was silently ignored and disko fell back
  to askPassword=true, prompting the user again on luksOpen. Move the
  option to the right scope.
- configure_impermanence now uses local rc, nrun gum confirm, and an
  explicit case (0/1/130) with a final return 0 so a No answer no
  longer aborts the installer.
- run_disko_with_retry hides disko's chatty output behind a gum spin
  by default and surfaces the captured log on failure. Set
  NOMARCHY_VERBOSE_DISKO=1 to stream output live.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-05-02 09:48:37 +01:00
parent 0af1395df2
commit 329dc009b6
2 changed files with 58 additions and 24 deletions

View File

@@ -869,17 +869,27 @@ configure_impermanence() {
info "This provides a clean, reproducible system."
echo ""
rc=0
gum confirm "Enable Impermanence?" || rc=$?
if [[ $rc -eq 0 ]]; then
ENABLE_IMPERMANENCE="true"
success "Impermanence enabled"
else
if [[ $rc -eq 130 ]]; then return 130; fi
ENABLE_IMPERMANENCE="false"
info "Impermanence disabled (traditional persistent root)"
fi
local rc=0
nrun gum confirm "Enable Impermanence?" || rc=$?
case "$rc" in
0)
ENABLE_IMPERMANENCE="true"
success "Impermanence enabled"
;;
1)
ENABLE_IMPERMANENCE="false"
info "Impermanence disabled (traditional persistent root)"
;;
130)
return 130
;;
*)
ENABLE_IMPERMANENCE="false"
info "Impermanence disabled (traditional persistent root)"
;;
esac
save_state
return 0
}
# ============================================================================
@@ -1084,6 +1094,10 @@ _LUKS_KEY_PATH="/dev/shm/nomarchy-luks.key"
# Wrap the disko invocation so a failure surfaces the last few lines of
# output and offers Retry / View full log / Abort. set -e is suspended for
# the disko call so we can inspect its exit code; restored on every path.
#
# By default disko's chatty output is hidden behind a `gum spin` spinner;
# the full log is captured and shown on failure or via `gum pager`. Set
# NOMARCHY_VERBOSE_DISKO=1 to stream disko output live instead.
run_disko_with_retry() {
local main_drive="$1"
local extras_nix="$2"
@@ -1093,13 +1107,33 @@ run_disko_with_retry() {
while true; do
local rc=0
set +e
disko --mode destroy,format,mount \
--argstr mainDrive "$main_drive" \
--arg extraDrives "$extras_nix" \
"$disko_file" 2>&1 | tee "$log"
rc=${PIPESTATUS[0]}
set -e
if [[ "$NOMARCHY_VERBOSE_DISKO" == "1" ]]; then
set +e
disko --mode destroy,format,mount \
--argstr mainDrive "$main_drive" \
--arg extraDrives "$extras_nix" \
"$disko_file" 2>&1 | tee "$log"
rc=${PIPESTATUS[0]}
set -e
else
# Silent path: run disko in the background, write all output to
# $log, and show a spinner. Use a status file for the exit code
# because `gum spin` doesn't propagate the wrapped command's rc.
local status_file
status_file=$(mktemp --suffix=.disko.rc)
set +e
nrun gum spin --spinner dot --title "Partitioning disk(s) with disko..." -- \
bash -c '
disko --mode destroy,format,mount \
--argstr mainDrive "$1" \
--arg extraDrives "$2" \
"$3" > "$4" 2>&1
echo $? > "$5"
' _ "$main_drive" "$extras_nix" "$disko_file" "$log" "$status_file"
set -e
rc=$(cat "$status_file" 2>/dev/null || echo 1)
rm -f "$status_file"
fi
if [[ $rc -eq 0 ]]; then
rm -f "$log"
@@ -1197,11 +1231,11 @@ execute_installation() {
info "Initializing git repository..."
(
cd /mnt/etc/nixos
nrun git git init -q
nrun git git add .
nrun git git config user.name "Nomarchy Installer"
nrun git git config user.email "installer@nomarchy"
nrun git git commit -qm "Initial Nomarchy configuration"
nrun git init -q
nrun git add .
nrun git config user.name "Nomarchy Installer"
nrun git config user.email "installer@nomarchy"
nrun git commit -qm "Initial Nomarchy configuration"
)
success "Git repository initialized"