fix(waybar): supervisor respawn + clean-restart switches; add sys-rebuild
Recovers the crashed iteration #7 (items 21+23, Latitude QA findings): - nomarchy-waybar supervisor (waybar.nix, exec-once'd from hyprland.nix): any waybar exit respawns the bar; crash-loop guard (5 fast exits -> critical notify + stop); TERM trapped for a real stop. Fixes the bar-less session after a theme-switch crash. - nomarchy-theme-sync prefers a clean `pkill -x waybar` (supervisor restart with fresh config+style) over the crash-prone in-place SIGUSR2 reload when the supervisor is running; SIGUSR2 stays as the unsupervised fallback. - sys-rebuild: snapshot-first system rebuild against the CURRENT lock (no `nix flake update`) — the no-update twin of sys-update; README §3/§5 + motd list it. Verified: V0 re-run green after crash recovery (flake check --no-build + py_compile); V1/V2 per the crashed session's journal entry (HM renders exec-once=nomarchy-waybar; headless software-GL VM: SIGKILL -> new pid, clean kill -> respawn, SIGUSR2 -> alive). V3 pending on the Latitude (queued in HARDWARE-QUEUE.md). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -209,9 +209,10 @@ in
|
||||
# Waybar is launched here rather than as a systemd user service: bound
|
||||
# to graphical-session.target the unit raced Hyprland's IPC on relogin
|
||||
# and landed in `failed`; exec-once only fires once the compositor is
|
||||
# up. Reloaded on theme switch via SIGUSR2 (nomarchy-theme-sync). See
|
||||
# waybar.nix.
|
||||
] ++ lib.optional config.nomarchy.waybar.enable "waybar"
|
||||
# up. Via the nomarchy-waybar supervisor (waybar.nix): a crash — or
|
||||
# the clean pkill a theme switch now does — respawns the bar instead
|
||||
# of orphaning the session bar-less.
|
||||
] ++ lib.optional config.nomarchy.waybar.enable "nomarchy-waybar"
|
||||
++ lib.optional kbAutoSwitch "${keyboardWatch}/bin/nomarchy-keyboard-watch";
|
||||
|
||||
# ── Theme-driven look ──────────────────────────────────────────
|
||||
|
||||
@@ -28,6 +28,37 @@ let
|
||||
# Named writeShellScriptBins (put on PATH via home.packages below) rather
|
||||
# than bare writeShellScript store paths, so the whole-swap themes' static
|
||||
# waybar.jsonc can exec them by name too — same as the swaync bell.
|
||||
# Waybar supervisor — exec-once has no restart, so a crashed bar used to
|
||||
# leave the session bar-less until relogin (seen on hardware: a theme
|
||||
# switch crashed waybar mid-reload). Respawns on ANY exit — a plain
|
||||
# `pkill -x waybar` is now a clean restart, which nomarchy-theme-sync
|
||||
# uses instead of the crash-prone in-place SIGUSR2 reload when it sees
|
||||
# this supervisor running. Crash-loop guard: 5 exits within 10s of
|
||||
# their start → give up with a critical notification instead of
|
||||
# spinning. Stop the bar for real: pkill -f nomarchy-waybar (TERM is
|
||||
# trapped to take the child down too).
|
||||
waybarSupervisor = pkgs.writeShellScriptBin "nomarchy-waybar" ''
|
||||
child=
|
||||
trap '[ -n "$child" ] && kill "$child" 2>/dev/null; exit 0' TERM INT
|
||||
fails=0
|
||||
while :; do
|
||||
start=$(date +%s)
|
||||
waybar & child=$!
|
||||
wait "$child"; code=$?
|
||||
if [ $(( $(date +%s) - start )) -lt 10 ]; then
|
||||
fails=$((fails + 1))
|
||||
if [ "$fails" -ge 5 ]; then
|
||||
notify-send -u critical "Waybar" \
|
||||
"Crashing on start (exit $code) — check ~/.config/waybar. Giving up." 2>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
fails=0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
'';
|
||||
|
||||
powerProfileStatus = pkgs.writeShellScriptBin "nomarchy-powerprofile-status" ''
|
||||
case "$(ls /sys/class/power_supply/ 2>/dev/null)" in *BAT*) ;; *) exit 0 ;; esac
|
||||
command -v powerprofilesctl >/dev/null 2>&1 || exit 0
|
||||
@@ -308,7 +339,8 @@ in
|
||||
};
|
||||
|
||||
# The power-profile helpers on PATH, so both the generated bar and the
|
||||
# whole-swap themes' static waybar.jsonc can exec them by name.
|
||||
# whole-swap themes' static waybar.jsonc can exec them by name — plus
|
||||
# the supervisor hyprland.nix exec-onces.
|
||||
home.packages = lib.optionals config.nomarchy.waybar.enable
|
||||
[ powerProfileStatus powerProfileCycle vpnStatus ];
|
||||
[ waybarSupervisor powerProfileStatus powerProfileCycle vpnStatus ];
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ in
|
||||
${distroName} — a NixOS desktop, themed from one JSON.
|
||||
|
||||
sys-update update inputs + rebuild the system
|
||||
sys-rebuild rebuild the system, no input update
|
||||
home-update apply home/theme changes (no sudo)
|
||||
nomarchy-theme-sync apply <theme> switch the whole palette
|
||||
SUPER+? keybindings cheatsheet
|
||||
@@ -312,6 +313,23 @@ in
|
||||
sudo nixos-rebuild switch --flake "$flake#default" "$@"
|
||||
fi
|
||||
'')
|
||||
# The no-update twin (hardware-QA request): rebuild the system
|
||||
# against the CURRENT lock — config changes only, no `nix flake
|
||||
# update` — mirroring how home-update never touches the lock.
|
||||
# Same snapshot-first path when available.
|
||||
(pkgs.writeShellScriptBin "sys-rebuild" ''
|
||||
set -e
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "sys-rebuild: run as your normal user (it sudos the rebuild itself)" >&2
|
||||
exit 1
|
||||
fi
|
||||
flake="''${NOMARCHY_PATH:-$HOME/.nomarchy}"
|
||||
if command -v nixos-rebuild-snap >/dev/null 2>&1; then
|
||||
sudo nixos-rebuild-snap "$@" # BTRFS snapshot first
|
||||
else
|
||||
sudo nixos-rebuild switch --flake "$flake#default" "$@"
|
||||
fi
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "home-update" ''
|
||||
set -e
|
||||
exec home-manager switch --flake "''${NOMARCHY_PATH:-$HOME/.nomarchy}" "$@"
|
||||
|
||||
Reference in New Issue
Block a user