Files
Nomarchy/features/scripts/utils/nomarchy-installed-summary
Bernardo Magri 8e5e63facb fix(installed-summary): drop compgen (absent in wrapped bash)
Booting the VM showed "line 31: compgen: command not found" from
nomarchy-installed-summary on first boot. compgen is a bash
programmable-completion builtin, and the non-interactive bash the script
gets wrapped with (via makeWrapper + patchShebangs) is compiled without
progcomp. Beyond the visible error, the battery-presence check silently
failed to the else branch, so a laptop was always reported as "desktop".
Replace `compgen -G` with a nullglob array (a shopt, always available).
The installer's identical check runs under the ISO's interactive bash, so
it was unaffected — this script is the only compgen user.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 21:30:35 +01:00

105 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# Print a curated "what the installer wrote" summary so the user can verify
# the system shape on first boot before they start customising. Reads from
# state.json where the schema persists the value, and falls back to live
# introspection for things the schema doesn't track (form factor, drives,
# active software profiles, FDE).
#
# Invoked as Step 0 of nomarchy-welcome and available as a standalone CLI.
HOME_STATE="$HOME/.config/nomarchy/state.json"
SYS_STATE="/etc/nixos/state.json"
jq_or_empty() {
local file="$1"
local query="$2"
[[ -f "$file" ]] || { echo ""; return; }
jq -r "$query // empty" "$file" 2>/dev/null || echo ""
}
theme=$(jq_or_empty "$HOME_STATE" '.theme')
font=$(jq_or_empty "$HOME_STATE" '.font')
panel=$(jq_or_empty "$HOME_STATE" '.panelPosition')
tz=$(jq_or_empty "$SYS_STATE" '.timezone')
dns=$(jq_or_empty "$SYS_STATE" '.dns')
hybrid_gpu=$(jq_or_empty "$SYS_STATE" '.features.hybridGPU')
# Form factor: battery presence (same signal the installer uses to auto-set
# nomarchy.{system.,}formFactor). `compgen` is a bash programmable-completion
# builtin, and the non-interactive bash this script gets wrapped with is
# compiled without it — so a glob into a nullglob array, not `compgen -G`.
shopt -s nullglob
batteries=( /sys/class/power_supply/BAT* )
shopt -u nullglob
if (( ${#batteries[@]} )); then
form_factor="laptop"
else
form_factor="desktop"
fi
# Active software profiles: heuristic detection. The installer bakes the
# user's pick into the generated home.nix as concrete `home.packages` /
# system toggles rather than persisting a profile list, so we check for
# the marker package of each profile.
profiles=()
command -v docker >/dev/null 2>&1 && profiles+=("Dev")
command -v steam >/dev/null 2>&1 && profiles+=("Gaming")
command -v libreoffice >/dev/null 2>&1 && profiles+=("Office")
command -v obs >/dev/null 2>&1 && profiles+=("Media")
command -v rg >/dev/null 2>&1 && profiles+=("CLI Utils")
profiles_str="None"
if (( ${#profiles[@]} > 0 )); then
profiles_str="$(IFS=', '; echo "${profiles[*]}")"
fi
# FDE: any crypt device present means the install used LUKS.
luks="No"
if lsblk -no TYPE 2>/dev/null | grep -q '^crypt$'; then
luks="Yes"
fi
# Drives: target disks + their mounted root/boot/crypt partitions. Filter
# noise (loop/rom/zram) so the table reads like an install receipt.
drives=$(lsblk -no NAME,SIZE,TYPE,MOUNTPOINT 2>/dev/null \
| grep -Ev '^(loop|sr|zram)' \
| awk 'NF>=3 && $3 ~ /^(disk|part|crypt)$/' \
|| true)
version_line=$(nomarchy-version 2>/dev/null || echo "Nomarchy")
hostname_line="$(hostname 2>/dev/null || echo "")"
# Render via gum format (markdown). Fallback to plain text when gum isn't
# on PATH — keeps the script callable from minimal contexts like recovery.
render() {
cat <<MD
# $version_line on \`$hostname_line\`
| Setting | Value |
| --- | --- |
| Theme | ${theme:-—} |
| Font | ${font:-—} |
| Panel | ${panel:-—} |
| Form factor | $form_factor |
| Timezone | ${tz:-—} |
| DNS | ${dns:-—} |
| Hybrid GPU | ${hybrid_gpu:-false} |
| Profiles | $profiles_str |
| FDE (LUKS) | $luks |
## Drives
\`\`\`
$drives
\`\`\`
MD
}
if command -v gum >/dev/null 2>&1; then
render | gum format
else
render
fi