Skip to content

Commit 6a2018c

Browse files
update vendor hash and add workflow to automate this
1 parent 371d3eb commit 6a2018c

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Nix builds require a pre-computed hash (vendorHash) of all Go dependencies.
2+
# This hash lives in flake.nix and must match the actual dependencies exactly —
3+
# if go.mod/go.sum change but vendorHash isn't updated, the Nix build breaks.
4+
#
5+
# This workflow automatically recalculates the hash whenever Go dependencies
6+
# change, so contributors don't need Nix installed locally to keep it in sync.
7+
#
8+
# Similar workflows in other repos:
9+
# https://github.com/open-component-model/ocm/blob/main/.github/workflows/flake_vendorhash.yaml
10+
# https://github.com/Tarow/dockdns/blob/main/.github/workflows/go_vendorhash.yaml
11+
# https://github.com/Mic92/sops-nix/blob/master/.github/workflows/update-vendor-hash.yml
12+
name: Update Nix vendorHash
13+
14+
on:
15+
push:
16+
branches:
17+
- master
18+
paths:
19+
- go.mod
20+
- go.sum
21+
pull_request:
22+
branches:
23+
- master
24+
paths:
25+
- go.mod
26+
- go.sum
27+
28+
jobs:
29+
update-vendor-hash:
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write
33+
steps:
34+
- uses: actions/checkout@v6
35+
with:
36+
ref: ${{ github.head_ref || github.ref_name }}
37+
38+
- uses: DeterminateSystems/nix-installer-action@main
39+
40+
# nix-update recalculates vendorHash by building the Go module fetcher,
41+
# comparing the expected vs actual hash, and patching flake.nix in-place.
42+
# --version=skip tells it to only update hashes, not the package version.
43+
- name: Update vendorHash
44+
run: nix run nixpkgs#nix-update -- --flake --version=skip flow-cli
45+
46+
- name: Commit updated vendorHash
47+
run: |
48+
git diff --quiet flake.nix && exit 0
49+
git config user.name "github-actions[bot]"
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
git add flake.nix
52+
git commit -m "flake: update vendorHash"
53+
git push

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
version = version;
3939
src = ./.;
4040

41-
vendorHash = "sha256-EYQfXvHiRftod45Rvi7dUHF+3G5PyDtdM+HmJsE5r4I=";
41+
vendorHash = "sha256-y0oj00qSyHvILYbtgWQT1fUdlhrQgXVtwtowvR7Cg0Q=";
4242
proxyVendor = true;
4343

4444
subPackages = [ "cmd/flow" ];

0 commit comments

Comments
 (0)