From 7590fc40572d57582eda1ba0ffcc08a3bd8f5560 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Fri, 10 Apr 2026 20:22:13 +0100 Subject: [PATCH] fix(install): fix gum syntax and TTY redirection in bootstrap script --- install.sh | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 52ee190..a48eb90 100644 --- a/install.sh +++ b/install.sh @@ -1,17 +1,40 @@ #!/usr/bin/env bash set -e -# Use Nix to temporarily pull in Gum for a beautiful UI -NIX_RUN="nix run --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#gum --" +# Define a wrapper for gum to handle Nix run fallback and TTY redirection +gum() { + local cmd="$1" + shift + local GUM_CMD + if command -v gum >/dev/null 2>&1; then + GUM_CMD="gum" + else + # Use --quiet to avoid progress bars in captured output + GUM_CMD="nix run --quiet --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#gum --" + fi + + case "$cmd" in + input|confirm|choose|filter|write) + $GUM_CMD "$cmd" "$@" < /dev/tty + ;; + *) + $GUM_CMD "$cmd" "$@" + ;; + esac +} clear -$NIX_RUN style --border double --margin "1" --padding "1 2" --border-foreground 212 "Nomarchy OS Bootstrap" +gum style \ + --foreground 212 --border-foreground 212 --border double \ + --align center --width 50 --margin "1 2" --padding "2 4" \ + "NOMARCHY" "The Omarchy-flavored NixOS" + echo "This script will generate your private downstream environment." echo "" # 1. Gather User Information -USERNAME=$($NIX_RUN input --placeholder "Enter your Linux username") -HOSTNAME=$($NIX_RUN input --placeholder "Enter a hostname for this machine (e.g., nomarchy-sys)") +USERNAME=$(gum input --placeholder "Enter your Linux username") +HOSTNAME=$(gum input --placeholder "Enter a hostname for this machine (e.g., nomarchy-sys)") # 2. Setup the Local Directory LOCAL_DIR="$HOME/.nomarchy" @@ -100,10 +123,13 @@ nix run nixpkgs#git -- -C "$LOCAL_DIR" add . # 7. Execution clear -$NIX_RUN style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Ready for Genesis" +gum style \ + --foreground 212 --border-foreground 212 --border normal \ + --align center --width 50 --margin "1 2" --padding "1 2" \ + "Ready for Genesis" echo "Your private downstream configuration has been generated." -if $NIX_RUN confirm "Build Nomarchy OS now? (This will take a few minutes)"; then +if gum confirm "Build Nomarchy OS now? (This will take a few minutes)"; then echo "Building System Engine..." sudo nixos-rebuild switch --flake "$LOCAL_DIR#$HOSTNAME" --extra-experimental-features "nix-command flakes" @@ -111,8 +137,11 @@ if $NIX_RUN confirm "Build Nomarchy OS now? (This will take a few minutes)"; the nix run home-manager/release-25.11 -- switch --flake "$LOCAL_DIR#$USERNAME" clear - $NIX_RUN style --border double --margin "1" --padding "1 2" --border-foreground 212 "Installation Complete" + gum style \ + --foreground 212 --border-foreground 212 --border double \ + --align center --width 50 --margin "1 2" --padding "2 4" \ + "Installation Complete" echo "Welcome to Nomarchy OS. Reboot to enter your new environment." else echo "Aborted. You can review your files in $LOCAL_DIR and run the build manually later." -fi \ No newline at end of file +fi