@@ -72,15 +72,51 @@ jobs:
7272
7373 docker :
7474 runs-on : ubuntu-latest
75+ permissions :
76+ contents : write
7577 steps :
7678 - uses : actions/checkout@v6
79+ with :
80+ ref : ${{ github.head_ref || github.ref }}
7781
7882 - name : Install Nix
7983 uses : cachix/install-nix-action@v31
8084 with :
8185 nix_path : nixpkgs=channel:nixos-25.11
8286
83- - name : Build Docker images (amd64 + arm64 )
87+ - name : Build Docker images (fix Nix hashes if needed )
8488 run : |
85- nix build .#docker -o result-amd64
89+ # Build amd64, auto-fixing hash mismatches (up to 3 rounds for
90+ # npmDeps + vendorHash + verify)
91+ for attempt in 1 2 3; do
92+ echo "=== Build attempt $attempt ==="
93+ if nix build .#docker -o result-amd64 2>build-err.log; then
94+ break
95+ fi
96+
97+ cat build-err.log >&2
98+ NEW_HASH=$(grep -oE 'got:[[:space:]]+[^ ]+' build-err.log | sed 's/got:[[:space:]]*//')
99+ if [ -z "$NEW_HASH" ]; then
100+ echo "Build failed without a hash mismatch"
101+ exit 1
102+ fi
103+
104+ if grep -q 'npm-deps' build-err.log; then
105+ echo "Fixing npmDeps hash: $NEW_HASH"
106+ sed -i "/fetchNpmDeps/,/};/ s|hash = \".*\"|hash = \"$NEW_HASH\"|" flake.nix
107+ else
108+ echo "Fixing vendorHash: $NEW_HASH"
109+ sed -i "s|vendorHash = \".*\"|vendorHash = \"$NEW_HASH\"|" flake.nix
110+ fi
111+ done
112+
86113 nix build .#docker-arm64 -o result-arm64
114+
115+ - name : Commit hash fix
116+ run : |
117+ git diff --quiet flake.nix && exit 0
118+ git config user.name "github-actions[bot]"
119+ git config user.email "github-actions[bot]@users.noreply.github.com"
120+ git add flake.nix
121+ git commit -m "fix: update Nix hashes for dependency changes"
122+ git push
0 commit comments