feat(lifecycle): plain-language generation diffs (#82)
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:
Bernardo Magri
2026-07-11 10:26:57 +01:00
parent 8f720b1078
commit 639f553cb7
10 changed files with 335 additions and 14 deletions

View File

@@ -87,9 +87,11 @@
nomarchy-control-center = final.callPackage ./pkgs/nomarchy-control-center { };
nomarchy-battery-notify = final.callPackage ./pkgs/nomarchy-battery-notify { };
nomarchy-first-boot = final.callPackage ./pkgs/nomarchy-first-boot { };
nomarchy-what-changed = final.callPackage ./pkgs/nomarchy-what-changed { };
nomarchy-detect-hw = final.callPackage ./pkgs/nomarchy-detect-hw { };
# pull / rebuild / home (+ legacy aliases) — also on HM so a home
# switch can refresh a broken system-package nomarchy-pull.
# Includes nomarchy-what-changed (generation readability, #82).
nomarchy-lifecycle = final.callPackage ./pkgs/nomarchy-lifecycle { };
};
@@ -126,6 +128,7 @@
nomarchy-control-center = pkgs.nomarchy-control-center;
nomarchy-battery-notify = pkgs.nomarchy-battery-notify;
nomarchy-first-boot = pkgs.nomarchy-first-boot;
nomarchy-what-changed = pkgs.nomarchy-what-changed;
nomarchy-detect-hw = pkgs.nomarchy-detect-hw;
default = pkgs.nomarchy-theme-sync;
};
@@ -746,6 +749,71 @@
'';
};
# Generation readability (#82): nomarchy-what-changed turns an
# nvd report into plain-language counts. Inject a fake nvd via
# NOMARCHY_NVD so the VM stays minimal (no real store closures).
what-changed = pkgs.testers.runNixOSTest {
name = "nomarchy-what-changed";
nodes.machine = { ... }: {
environment.systemPackages = [ pkgs.nomarchy-what-changed ];
};
testScript = ''
machine.wait_for_unit("multi-user.target")
# Fake nvd: args are `nvd --color never diff A B` ignore paths.
machine.succeed(
"mkdir -p /shim && cat > /shim/fake-nvd <<'EOF'\n"
"#!/bin/sh\n"
"cat <<'R'\n"
"<<< /nix/store/old\n"
">>> /nix/store/new\n"
"Added packages:\n"
"[A.] #1 hello 2.12\n"
"[A.] #2 cowsay 3.04\n"
"Removed packages:\n"
"[R.] #1 fortune 1.0\n"
"Version changes:\n"
"[C.] #1 bash: 5.2 -> 5.3\n"
"Closure size: 100 -> 105 (10 paths added, 5 paths removed, delta +5).\n"
"R\n"
"EOF\n"
"chmod +x /shim/fake-nvd"
)
# Dummy before/after paths (script only needs them to exist and differ).
machine.succeed("mkdir -p /tmp/gen-a /tmp/gen-b && touch /tmp/gen-a/x /tmp/gen-b/y")
out = machine.succeed(
"NOMARCHY_NVD=/shim/fake-nvd nomarchy-what-changed --summary "
"--diff /tmp/gen-a /tmp/gen-b"
)
assert "2 added" in out, f"missing added count:\n{out}"
assert "1 removed" in out, f"missing removed count:\n{out}"
assert "1 updated" in out, f"missing updated count:\n{out}"
# Identical paths no package changes (no nvd call needed).
out2 = machine.succeed(
"NOMARCHY_NVD=/shim/fake-nvd nomarchy-what-changed --summary "
"--diff /tmp/gen-a /tmp/gen-a"
)
assert "no package changes" in out2, f"identical paths should short-circuit:\n{out2}"
# Empty-ish nvd report.
machine.succeed(
"cat > /shim/fake-nvd-empty <<'EOF'\n"
"#!/bin/sh\n"
"echo 'No version or selection state changes.'\n"
"echo 'Closure size: 1 -> 1 (0 paths added, 0 paths removed, delta +0).'\n"
"EOF\n"
"chmod +x /shim/fake-nvd-empty"
)
out3 = machine.succeed(
"NOMARCHY_NVD=/shim/fake-nvd-empty nomarchy-what-changed --summary "
"--diff /tmp/gen-a /tmp/gen-b"
)
assert "no package changes" in out3, f"empty report:\n{out3}"
'';
};
# Memory-pressure protection (oom.nix): earlyoom must kill a
# runaway allocator BEFORE the kernel thrash point — and must not
# take anything else with it. A bystander unit survives the kill,