Skip to content

flake.nix, tool/updateflakes: keep the nix vendor hash fresh automatically - #54

Merged
bradfitz merged 1 commit into
mainfrom
bradfitz/nix_tidy
Aug 31, 2026
Merged

flake.nix, tool/updateflakes: keep the nix vendor hash fresh automatically#54
bradfitz merged 1 commit into
mainfrom
bradfitz/nix_tidy

Conversation

@bradfitz

Copy link
Copy Markdown
Member

The flake hard-coded buildGoModule's vendorHash, and three go.mod
changes later it was stale, breaking nix build for anyone using the
flake.

Port tailscale.com's updateflakes tool (minus its custom toolchain
handling): "make tidy" runs go mod tidy and then recomputes the vendor
tree's SRI hash in pure Go via tailscale.com/cmd/nardump/nardump,
recording it in flakehashes.json, which flake.nix now reads with
builtins.fromJSON. The JSON also records a go.mod/go.sum fingerprint
so repeat runs are no-ops, and a cache busting line in flake.nix makes
nix-direnv re-evaluate when the hash changes.

A new tidy CI job runs "make tidy" and fails on any resulting diff, so
a PR that changes dependencies without refreshing the hash can't land.
No nix is required on the CI runner.

Fixes #53

…cally

The flake hard-coded buildGoModule's vendorHash, and three go.mod
changes later it was stale, breaking nix build for anyone using the
flake.

Port tailscale.com's updateflakes tool (minus its custom toolchain
handling): "make tidy" runs go mod tidy and then recomputes the vendor
tree's SRI hash in pure Go via tailscale.com/cmd/nardump/nardump,
recording it in flakehashes.json, which flake.nix now reads with
builtins.fromJSON. The JSON also records a go.mod/go.sum fingerprint
so repeat runs are no-ops, and a cache busting line in flake.nix makes
nix-direnv re-evaluate when the hash changes.

A new tidy CI job runs "make tidy" and fails on any resulting diff, so
a PR that changes dependencies without refreshing the hash can't land.
No nix is required on the CI runner.

Fixes #53

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I9f3c7b21ae584d0c6e2b58f14ad7c93b02c46d1e
@bradfitz
bradfitz merged commit deece63 into main Aug 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake.nix: stale vendorHash at 4d50a34 — nix build fails with hash mismatch

1 participant