feat(menu): #76 slice 2 — Hibernate notifies on failure
All checks were successful
Check / eval (push) Successful in 4m7s

Per the settled #76 UX call: keep the Power-menu Hibernate row
unconditional, but when hibernate fails (typically a swap=0 machine with
no disk swap), surface a notification pointing at the enable-hibernation
runbook instead of a silent no-op. On success `systemctl hibernate`
blocks until resume, so the notify only fires on a real failure.

Verification: V1 — homeConfigurations.nomarchy.activationPackage builds
(rebuilds nomarchy-menu; writeShellScriptBin runs bash -n). Control-flow
proved on the arm extracted from the built script: failing systemctl ->
notify fires, succeeding -> no notify. flake check --no-build green.
V2 hibernate->resume VM test + V3 laptop remain open (#76 slice 3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-07-10 19:36:52 +01:00
parent 8c048a2692
commit 2d0cb48d5c
3 changed files with 33 additions and 3 deletions

View File

@@ -75,8 +75,13 @@ interplay handled in `modules/nixos/default.nix` / `modules/home/idle.nix`.
1. ~~**Docs** — `docs/MIGRATION.md` hibernation-enable runbook (V0).~~
shipped 2026-07-10 (§ "Enabling hibernation on an existing machine";
commands verified live against the dev machine's LUKS+@swap layout).
2. **Menu** — Hibernate row: notify-on-failure when no swap configured
(behavioral, V1/V2). Keep the row unconditional.
2. ~~**Menu** — Hibernate row: notify-on-failure when no swap configured.~~
✓ shipped 2026-07-10 (`rofi.nix` power arm: `systemctl hibernate ||
notify-send …`; success blocks until resume so the notify only fires on
real failure). V1 (HM generation builds; `writeShellScriptBin` bash -n) +
control-flow proof (fail→notify, success→no notify). Row kept unconditional.
The session-level "no-swap pick surfaces a mako notification" is folded
into the V3 laptop check below.
3. **Verify (required)**
- **V0:** eval / option / disko contracts.
- **V2 (mandatory, agent):** exercise hibernation in the **VM harness**

View File

@@ -17,6 +17,25 @@ Template:
---
## 2026-07-10 — #76 slice 2: Hibernate notify-on-failure
- **Task:** BACKLOG #76 remaining slice 2 — per the settled "keep row, notify
on failure" call.
- **Did:** `modules/home/rofi.nix` power menu Hibernate arm now runs
`systemctl hibernate 2>/dev/null || notify-send "Hibernate" "…see
docs/MIGRATION.md"`. On success the call blocks until resume, so the notify
only fires on a genuine failure (e.g. swap=0 no-swap machine). Row stays
unconditional (no hiding).
- **Verified:** **V1**`nix build …homeConfigurations.nomarchy.activationPackage`
green (rebuilds `nomarchy-menu.drv`; `writeShellScriptBin` runs bash -n at
build). Control-flow proof on the arm extracted from the built script:
failing `systemctl` → notify fires; succeeding → no notify. `nix flake
check --no-build` green.
- **Pending:** slice 3 = the V2 hibernate→resume VM test + V3 laptop
(Hibernate→power off→resume on the LUKS+@swap machine; plus confirm the
no-swap notify surfaces in a real session). Both remain open on #76.
- **Next suggestion:** slice 3 — add a `checks.*` hibernate VM test (as far
as QEMU allows) and queue the V3 laptop steps in HARDWARE-QUEUE.
## 2026-07-10 — #76 slice 1: MIGRATION.md hibernation runbook
- **Task:** BACKLOG #76 remaining slice 1 — docs runbook for enabling
hibernation on an existing machine (per the settled "docs not tool" call).

View File

@@ -252,7 +252,13 @@ let
*Lock) loginctl lock-session ;;
*Logout) hyprctl dispatch exit ;;
*Suspend) systemctl suspend ;;
*Hibernate) systemctl hibernate ;;
*Hibernate)
# zram can't hold a hibernate image; a machine installed with
# swap=0 has no disk swap. Attempt, and if logind rejects it,
# say why instead of a silent no-op. On success this blocks
# until resume, so the notify only fires on a real failure.
systemctl hibernate 2>/dev/null \
|| notify-send "Hibernate" "Couldn't hibernate likely no swap is configured. See docs/MIGRATION.md Enabling hibernation." ;;
*Reboot) systemctl reboot ;;
*Shutdown) systemctl poweroff ;;
esac ;;