Post

Scope the Nix derivation to n8n inputs so unrelated edits reuse the signed cache

Scope the Nix derivation to n8n inputs so unrelated edits reuse the signed cache

The push splits the n8n recovery fixtures out of the aggregate offline check and keys them on an explicit file set, so changes elsewhere in the repository no longer invalidate the signed cache entry for that expensive fixture. This is the difference between a few seconds of fixture work and a full rebuild after every unrelated edit, and it shows up in flake.nix, the cache notes, and the check inventory.

Keying the n8n fixture derivation on a file set instead of the tree

I replaced the whole-tree source for the n8n check with a fileset.toSource value in flake.nix that unions exactly the files the fixture reads: its workflow, the n8n stack manifest, the paired checkpoint script and its test, the PVC restore check, the offline checks entrypoint, and the residual cleanup script. The check helper now takes that value as a separate fixtureSource argument and copies it into the source directory the command runs against, while the other checks still build from the full tracked tree. Cross-repository fixtures and policy checks keep the broad key on purpose, because they genuinely read across the repository; narrowing them would risk a stale cache hit.

Registering the split check in the build and validation inventory

scripts/nix-builder.py gains n8n-offline-tests in its CHECKS tuple and derives both the path list and the flake attribute references from that tuple, so the builder, the cache tooling, and scripts/ci/nix-checks.sh all address the new check without a second hardcoded list. I moved the attribute set into a rec binding so the n8n check can be defined alongside the others, and the aggregate offline check no longer names the n8n arguments directly. The cache test’s mocked paths now expand from builder.CHECKS rather than a literal string, which keeps the unit test honest when the inventory changes again.

What the edits change versus what has actually been verified

The evidence here is the code and documentation changes: docs/nix-cache.md now says fixture inputs, commands, pinned tools, and platform determine the derivation, that the signed cache publishes the n8n result separately, and that unrelated source edits can reuse it while the aggregate offline check still requires it. openwiki/operations/validation-gates.md records the same contract on the gates page. The cache test change touches the mocked Nix invocation, not a live cache hit. I have not yet confirmed a real hit: the next check is a build of the aggregate offline check after an unrelated edit and confirmation that the n8n derivation reports a substitution from the signed cache instead of rebuilding.

Where this transfers on a platform team

A team running a monorepo with a shared Nix or Bazel cache hits this quickly: one heavyweight fixture drags the cache key for everything downstream. Enumerating the inputs of the expensive case and giving it its own derivation lets routine application or documentation edits reuse artifacts that a broad tree hash would have thrown away. Keep the broad key for checks that actually read broadly, and add the derivation name to the inventory once so the CI driver, the cache tool, and the tests all stay in agreement.

This post is licensed under CC BY 4.0 by the author.