|
| 1 | +name: Nix |
| 2 | + |
| 3 | +# nix/package.nix records `npmDepsHash`, a hash of the npm dependency set that |
| 4 | +# package-lock.json resolves to. The two have to agree or `nix build` fails |
| 5 | +# outright, and nothing here ever checked that they did. |
| 6 | +# |
| 7 | +# The only thing that refreshed the hash was bump-nix-package.yml, which fires |
| 8 | +# on stable releases. `src` is this repo's own tree, not a fetched tarball, so |
| 9 | +# every lockfile change landing between two releases left main's hash pointing |
| 10 | +# at dependencies that no longer existed. It last matched on 2026-07-05 (v1.6.0) |
| 11 | +# while package-lock.json moved ten more times, so `nix run github:…` was broken |
| 12 | +# for four weeks with nothing reporting it. |
| 13 | +# |
| 14 | +# Release-time bumps can't fix that — the drift starts the moment a lockfile PR |
| 15 | +# merges. This runs on the PR that causes it and prints the hash to paste. |
| 16 | +on: |
| 17 | + pull_request: |
| 18 | + paths: |
| 19 | + - package-lock.json |
| 20 | + - nix/** |
| 21 | + - .github/workflows/nix-check.yml |
| 22 | + # Same branch list as ci.yml, and for the reason its own comment gives: a |
| 23 | + # release branch is the last place to skip a check. PRs need no filter here — |
| 24 | + # the trigger above has none, so they are covered wherever they land — but a |
| 25 | + # direct push or a rebase force-push onto a long-lived branch is not a PR and |
| 26 | + # would otherwise go unchecked. |
| 27 | + push: |
| 28 | + branches: [main, feat/ai-edition, "release/**"] |
| 29 | + paths: |
| 30 | + - package-lock.json |
| 31 | + - nix/** |
| 32 | + - .github/workflows/nix-check.yml |
| 33 | + |
| 34 | +# Read-only, and stated rather than inherited: the repo default happens to be |
| 35 | +# `read` today, which is exactly the kind of repo-level setting that silently |
| 36 | +# changed this workflow's sibling out from under it. |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + |
| 40 | +jobs: |
| 41 | + npm-deps-hash: |
| 42 | + name: npmDepsHash matches package-lock.json |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - uses: cachix/install-nix-action@v27 |
| 48 | + with: |
| 49 | + nix_path: nixpkgs=channel:nixos-unstable |
| 50 | + extra_nix_config: | |
| 51 | + experimental-features = nix-command flakes |
| 52 | +
|
| 53 | + - name: Compare recorded hash against the lockfile |
| 54 | + run: | |
| 55 | + set -euo pipefail |
| 56 | + EXPECTED=$(nix run nixpkgs#prefetch-npm-deps -- package-lock.json) |
| 57 | + RECORDED=$(sed -nE 's|^[[:space:]]*npmDepsHash[[:space:]]*=[[:space:]]*"([^"]*)";|\1|p' nix/package.nix) |
| 58 | +
|
| 59 | + echo "recorded in nix/package.nix: ${RECORDED:-<none>}" |
| 60 | + echo "expected from package-lock.json: $EXPECTED" |
| 61 | +
|
| 62 | + if [[ -z "$EXPECTED" ]]; then |
| 63 | + echo "::error::prefetch-npm-deps returned an empty hash" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +
|
| 67 | + if [[ "$EXPECTED" != "$RECORDED" ]]; then |
| 68 | + echo "::error file=nix/package.nix::npmDepsHash is stale — set it to $EXPECTED" |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | +
|
| 72 | + echo "In sync." |
0 commit comments