feat(lifecycle): plain-language generation diffs (#82)
Some checks failed
Check / eval (push) Has been cancelled
Some checks failed
Check / eval (push) Has been cancelled
nomarchy-what-changed wraps nvd into "N added, M removed, K updated" summaries. nomarchy-rebuild / nomarchy-home print full nvd and toast the one-liner; System › What changed? offers toast + floating report. checks.what-changed fixtures nvd via NOMARCHY_NVD. Verified: V2 — flake check --no-build; checks.what-changed green; local smoke on real HM generations.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# Installed on both NixOS (systemPackages) and Home Manager so a home
|
||||
# switch can refresh them without waiting for a full system rebuild —
|
||||
# otherwise a broken nomarchy-pull can never update itself.
|
||||
{ lib, writeShellScriptBin, nvd, jq, symlinkJoin }:
|
||||
{ lib, writeShellScriptBin, nvd, jq, symlinkJoin, nomarchy-what-changed }:
|
||||
|
||||
let
|
||||
# Shared preamble: refuse root, resolve flake path.
|
||||
@@ -78,6 +78,13 @@ let
|
||||
else
|
||||
echo "nomarchy-rebuild: what changed:"
|
||||
${nvd}/bin/nvd diff "$before" "$after" || true
|
||||
# One-line toast for the session (full report already on the terminal).
|
||||
if command -v notify-send >/dev/null 2>&1 \
|
||||
&& command -v nomarchy-what-changed >/dev/null 2>&1; then
|
||||
body=$(nomarchy-what-changed --summary --diff "$before" "$after" 2>/dev/null \
|
||||
| sed 's/^Diff: //' || true)
|
||||
[ -n "''${body:-}" ] && notify-send -a Nomarchy "System rebuild" "$body" || true
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
|
||||
@@ -87,6 +94,16 @@ let
|
||||
echo "nomarchy-home: no flake.nix at $flake" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Snapshot the active HM generation before the switch so we can nvd it.
|
||||
hm_before=""
|
||||
for d in \
|
||||
"''${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles" \
|
||||
"/nix/var/nix/profiles/per-user/$(id -un)"; do
|
||||
if [ -L "$d/home-manager" ]; then
|
||||
hm_before=$(readlink -f "$d/home-manager" 2>/dev/null || true)
|
||||
break
|
||||
fi
|
||||
done
|
||||
log=$(mktemp)
|
||||
trap 'rm -f "$log"' EXIT
|
||||
set +e
|
||||
@@ -102,7 +119,27 @@ let
|
||||
echo "Recovery: home-manager generations (or docs/RECOVERY.md)"
|
||||
exit "$rc"
|
||||
fi
|
||||
echo "nomarchy-home: desktop applied."
|
||||
hm_after=""
|
||||
for d in \
|
||||
"''${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles" \
|
||||
"/nix/var/nix/profiles/per-user/$(id -un)"; do
|
||||
if [ -L "$d/home-manager" ]; then
|
||||
hm_after=$(readlink -f "$d/home-manager" 2>/dev/null || true)
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -n "$hm_before" ] && [ -n "$hm_after" ] && [ "$hm_before" != "$hm_after" ]; then
|
||||
echo "nomarchy-home: what changed:"
|
||||
${nvd}/bin/nvd diff "$hm_before" "$hm_after" || true
|
||||
if command -v notify-send >/dev/null 2>&1 \
|
||||
&& command -v nomarchy-what-changed >/dev/null 2>&1; then
|
||||
body=$(nomarchy-what-changed --summary --diff "$hm_before" "$hm_after" 2>/dev/null \
|
||||
| sed 's/^Diff: //' || true)
|
||||
[ -n "''${body:-}" ] && notify-send -a Nomarchy "Desktop updated" "$body" || true
|
||||
fi
|
||||
else
|
||||
echo "nomarchy-home: desktop applied."
|
||||
fi
|
||||
'';
|
||||
|
||||
# Legacy aliases
|
||||
@@ -125,6 +162,7 @@ symlinkJoin {
|
||||
sys-update
|
||||
sys-rebuild
|
||||
home-update
|
||||
nomarchy-what-changed
|
||||
];
|
||||
meta = {
|
||||
description = "Nomarchy machine-flake lifecycle: pull, rebuild, home";
|
||||
|
||||
Reference in New Issue
Block a user