From 329dc009b6d211e56c1094c856c5e808664ba377 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Sat, 2 May 2026 09:48:37 +0100 Subject: [PATCH] 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 --- installer/disko-config.nix | 4 +- installer/install.sh | 78 +++++++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 24 deletions(-) diff --git a/installer/disko-config.nix b/installer/disko-config.nix index eb183a0..bcab696 100644 --- a/installer/disko-config.nix +++ b/installer/disko-config.nix @@ -44,8 +44,8 @@ let content = { type = "luks"; name = extraLuks drive; + passwordFile = "/dev/shm/nomarchy-luks.key"; settings.allowDiscards = true; - settings.passwordFile = "/dev/shm/nomarchy-luks.key"; content.type = "btrfs"; }; }; @@ -116,8 +116,8 @@ in { content = { type = "luks"; name = mainLuksName; + passwordFile = "/dev/shm/nomarchy-luks.key"; settings.allowDiscards = true; - settings.passwordFile = "/dev/shm/nomarchy-luks.key"; content = rootBtrfs; }; }; diff --git a/installer/install.sh b/installer/install.sh index efb517c..0699904 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -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"