Sweep across the three script directories: features/scripts/utils,
core/system/scripts, themes/engine/scripts. 142 of 169 bash scripts
gained `set -e`; 27 already had it; the one Python helper
(nomarchy-haptic-touchpad) was skipped via shebang detection.
Why: bash's default behavior is to continue past a failed command,
which means a script that does "do A; do B; do C" leaves the system
in a half-applied state when B fails - and the user gets no signal.
Several recent fix commits (theme partial-apply, waybar reload race,
installer prewipe silent failures) all trace back to this. set -e
turns silent corruption into a loud abort the user can act on.
The 11 scripts with explicit `|| true` markers stay safe under set -e
because || true coerces the exit to zero; the markers continue to
mean "I deliberately tolerate this failure here."
Deliberate exception: nomarchy-menu runs WITHOUT set -e. It is an
interactive UX loop where action branches do `cmd; back_to <self>`
so a failed action would abort the script under set -e and the menu
would disappear without feedback. Soft-failure - menu re-displays,
user picks again - is the right semantic. Documented inline.
Validation: bash -n on every modified script (zero failures). The
new pre-commit hook (27f5663) was just updated to filter by shebang
so it doesn't try to bash-syntax-check the Python helper - that
filter was uncovered by this sweep.
Risk: set -e can surface latent bugs in scripts that previously
relied on silent continuation. If anything breaks, it's a real bug
that was already broken and is now visible. Easy per-script revert
if any UX glitches show up.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
93 lines
2.7 KiB
Bash
Executable File
93 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
STATE_FILE="$HOME/.config/nomarchy/state.json"
|
|
|
|
# Check if welcome wizard has already been completed
|
|
if [ -f "$STATE_FILE" ]; then
|
|
DONE=$(jq -r '.welcome_done' "$STATE_FILE" 2>/dev/null)
|
|
if [ "$DONE" == "true" ]; then
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Ensure we have a terminal for the wizard
|
|
if [ -z "$TERMINAL_WIZARD" ]; then
|
|
export TERMINAL_WIZARD=1
|
|
alacritty -e "$0"
|
|
exit 0
|
|
fi
|
|
|
|
gum style \
|
|
--foreground 212 --border-foreground 212 --border double \
|
|
--align center --width 50 --margin "1 2" --padding "2 4" \
|
|
"Nomarchy" "The NixOS Distribution with Nomarchy Flavour"
|
|
|
|
echo "Welcome! Let's personalize your new system."
|
|
echo ""
|
|
|
|
# 1. Select initial theme
|
|
echo "Step 1: Choose your starting theme"
|
|
nomarchy-theme-set "$(nomarchy-theme-list | gum filter --placeholder 'Select a theme...')"
|
|
|
|
# 2. Select initial font
|
|
echo "Step 2: Choose your preferred font"
|
|
nomarchy-font-set "$(nomarchy-font-list | gum filter --placeholder 'Select a font...')"
|
|
|
|
# 3. Select panel position
|
|
echo "Step 3: Choose your preferred panel position"
|
|
POSITION=$(gum choose "top" "bottom")
|
|
nomarchy-state-write panelPosition "$POSITION"
|
|
|
|
# 4. Starter home.nix
|
|
echo ""
|
|
echo "Step 4: Starter home.nix"
|
|
HOME_NIX="$HOME/.config/home-manager/home.nix"
|
|
if [ ! -f "$HOME_NIX" ]; then
|
|
echo "It looks like you don't have a ~/.config/home-manager/home.nix file yet."
|
|
echo "Nomarchy uses this file to manage your user-level packages and settings."
|
|
if gum confirm "Would you like to generate a starter home.nix?"; then
|
|
mkdir -p "$(dirname "$HOME_NIX")"
|
|
cat <<EOF > "$HOME_NIX"
|
|
{ pkgs, ... }:
|
|
{
|
|
# Nomarchy starter home.nix
|
|
# Add your user packages here.
|
|
home.packages = with pkgs; [
|
|
btop
|
|
fastfetch
|
|
chromium
|
|
# Add more packages here
|
|
];
|
|
|
|
# home.stateVersion = "25.11"; # Consult docs/MIGRATION.md if you change this
|
|
}
|
|
EOF
|
|
echo "Starter home.nix generated at $HOME_NIX"
|
|
fi
|
|
else
|
|
echo "Detected existing home.nix at $HOME_NIX. Skipping generation."
|
|
fi
|
|
|
|
# 5. Setup Local Repo (Crucial for nomarchy-env-update to work)
|
|
echo ""
|
|
echo "Step 5: Git Repository Check"
|
|
echo "Nomarchy relies on a local git repository for declarative updates."
|
|
if [ ! -d "/etc/nixos/.git" ]; then
|
|
echo "Warning: /etc/nixos is not a git repository. Declarative updates might fail."
|
|
if gum confirm "Would you like to initialize /etc/nixos as a git repo?"; then
|
|
sudo git -C /etc/nixos init
|
|
sudo git -C /etc/nixos add .
|
|
sudo git -C /etc/nixos commit -m "Initial Nomarchy System Commit"
|
|
fi
|
|
fi
|
|
|
|
# 6. Success
|
|
nomarchy-state-write welcome_done true --type bool
|
|
|
|
# Remove legacy flag file if it exists
|
|
rm -f "$HOME/.config/nomarchy/.first-run-done"
|
|
|
|
gum style --foreground 82 "Setup complete! Enjoy your Nomarchy experience."
|
|
sleep 3
|