fix(install): fix gum syntax and TTY redirection in bootstrap script
This commit is contained in:
45
install.sh
45
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,7 +137,10 @@ 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."
|
||||
|
||||
Reference in New Issue
Block a user