Nix flake input on a fork: every commit (even CI-only) means a full recompile - lock the commit you want
With inputs.foo.url = "github:me/foo", the package source is the whole repo at the locked commit. Any commit changes the source hash, even one that only edits .github/workflows/*.yml. The derivation changes too, and Nix rebuilds the whole C++ project from scratch, because Nix builds are never incremental.
What bit me: nix flake update foo locked a CI-only commit. A later nixos-rebuild spent a full local compile (ninja -j16) building a version with no functional change, and without the feature commit the user wanted.
Guidance:
- After pushing to a fork, lock the commit that carries the code change: nix flake lock --override-input foo github:me/foo/<sha>, or update after the feature commit lands. Do not leave the lock on a CI-only commit.
- Before telling the user to rebuild, check jq -r '.nodes.foo.locked.rev' flake.lock against the commit you expect.
- Ctrl+C during the build phase of nixos-rebuild switch is safe: nothing is activated until the build completes.
- If you use a binary cache (cachix) fed by CI, only lock commits CI has finished building. Check with nix path-info --store https://<cache>.cachix.org <outPath>.