feat(lifecycle): auto-commit sweep of the machine flake before pull/rebuild/home
Some checks failed
Check / eval (push) Failing after 3m11s
Some checks failed
Check / eval (push) Failing after 3m11s
With settings.autoCommit on, only menu/theme mutations were committed (theme-sync pathspec-limits to theme-state.json by design), so hand edits to system.nix/home.nix and lock bumps stayed forever-dirty. New internal nomarchy-autocommit (nomarchy-lifecycle): live-reads the same flag, commits everything dirty as "nomarchy: auto-commit before <pull|rebuild|home switch>" with the swept file list in the body, fallback identity, never fatal (|| true at call sites). Called at the top of all three lifecycle commands; before the ff-only pull it also un-dirties the tree. Exposed via passthru.autocommit + package export; guarded by checks.lifecycle-autocommit (sandbox repos: sweep, no-op on clean/off/non-repo). Sync sweep: README, RECOVERY, ROADMAP, rofi toggle, control-center prompt, theme-sync docstring, JOURNAL. Verified: V1+ — flake check --no-build green; the new check builds; end-to-end run of the built nomarchy-rebuild (stubbed sudo/rebuild) against a copy of a real dirty ~/.nomarchy: 4 files → one commit, clean tree. No VM boot — no session-visible surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
50
flake.nix
50
flake.nix
@@ -125,6 +125,7 @@
|
||||
# Overlay tools exported for `nix build .#nomarchy-doctor` etc.
|
||||
# (maintainer/CI convenience — modules install them via the overlay).
|
||||
nomarchy-doctor = pkgs.nomarchy-doctor;
|
||||
nomarchy-lifecycle = pkgs.nomarchy-lifecycle;
|
||||
nomarchy-control-center = pkgs.nomarchy-control-center;
|
||||
nomarchy-battery-notify = pkgs.nomarchy-battery-notify;
|
||||
nomarchy-first-boot = pkgs.nomarchy-first-boot;
|
||||
@@ -259,6 +260,55 @@
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# The lifecycle "sweep before switch": with settings.autoCommit
|
||||
# on, nomarchy-pull/-rebuild/-home first commit every dirty file
|
||||
# in the machine flake (theme-sync's own auto_commit stays
|
||||
# pathspec-limited to theme-state.json). Exercises the real
|
||||
# helper binary against sandbox repos: flag on → one commit,
|
||||
# clean tree, fallback identity, file list in the body; clean
|
||||
# tree / flag off / no repo → untouched, never an error.
|
||||
lifecycle-autocommit = pkgs.runCommand "nomarchy-lifecycle-autocommit"
|
||||
{ nativeBuildInputs = [ pkgs.git ]; }
|
||||
''
|
||||
set -eu
|
||||
tool=${pkgs.nomarchy-lifecycle.autocommit}/bin/nomarchy-autocommit
|
||||
export HOME=$PWD # no global git config → fallback identity
|
||||
|
||||
mkdir flake && git -C flake init -q
|
||||
printf '{ "settings": { "autoCommit": true } }' > flake/theme-state.json
|
||||
echo base > flake/system.nix
|
||||
git -C flake add -A
|
||||
git -C flake -c user.name=T -c user.email=t@t commit -qm init
|
||||
|
||||
echo edit >> flake/system.nix
|
||||
echo lock > flake/flake.lock
|
||||
NOMARCHY_PATH=$PWD/flake $tool rebuild
|
||||
[ -z "$(git -C flake status --porcelain)" ] \
|
||||
|| { echo "FAIL: tree still dirty after sweep"; exit 1; }
|
||||
git -C flake log -1 --format=%s \
|
||||
| grep -qx 'nomarchy: auto-commit before rebuild'
|
||||
git -C flake log -1 --format=%ae | grep -qx 'nomarchy@localhost'
|
||||
git -C flake log -1 --format=%b | grep -q 'flake.lock'
|
||||
|
||||
# Clean tree → no new commit
|
||||
NOMARCHY_PATH=$PWD/flake $tool rebuild
|
||||
[ "$(git -C flake rev-list --count HEAD)" = 2 ]
|
||||
|
||||
# Flag off → dirty stays dirty, no commit
|
||||
printf '{ "settings": { "autoCommit": false } }' > flake/theme-state.json
|
||||
echo more >> flake/system.nix
|
||||
NOMARCHY_PATH=$PWD/flake $tool rebuild
|
||||
[ "$(git -C flake rev-list --count HEAD)" = 2 ]
|
||||
[ -n "$(git -C flake status --porcelain)" ]
|
||||
|
||||
# Not a git repo → silent no-op, exit 0
|
||||
mkdir plain
|
||||
printf '{ "settings": { "autoCommit": true } }' > plain/theme-state.json
|
||||
NOMARCHY_PATH=$PWD/plain $tool rebuild
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# Installer hardware DB ↔ nixos-hardware (item 49): every module
|
||||
# name the DB table and the CPU/GPU/chassis autodetect reference
|
||||
# must exist in the PINNED nixos-hardware.nixosModules — a lock
|
||||
|
||||
Reference in New Issue
Block a user