1 # `nixpkgs-vet` is a tool to vet Nixpkgs: its architecture, package structure, and more.
2 # Among other checks, it makes sure that `pkgs/by-name` (see `../../pkgs/by-name/README.md`) follows the validity rules outlined in [RFC 140](https://github.com/NixOS/rfcs/pull/140).
3 # When you make changes to this workflow, please also update `ci/nixpkgs-vet.sh` to reflect the impact of your work to the CI.
4 # See https://github.com/NixOS/nixpkgs-vet for details on the tool and its checks.
8 # Using pull_request_target instead of pull_request avoids having to approve first time contributors.
10 # This workflow depends on the base branch of the PR, but changing the base branch is not included in the default trigger events, which would be `opened`, `synchronize` or `reopened`.
11 # Instead it causes an `edited` event, so we need to add it explicitly here.
12 # While `edited` is also triggered when the PR title/body is changed, this PR action is fairly quick, and PRs don't get edited **that** often, so it shouldn't be a problem.
13 # There is a feature request for adding a `base_changed` event: https://github.com/orgs/community/discussions/35058
14 types: [opened, synchronize, reopened, edited]
18 # We don't use a concurrency group here, because the action is triggered quite often (due to the PR edit trigger), and contributors would get notified on any canceled run.
19 # There is a feature request for suppressing notifications on concurrency-canceled runs: https://github.com/orgs/community/discussions/13015
24 # This needs to be x86_64-linux, because we depend on the tooling being pre-built in the GitHub releases.
25 runs-on: ubuntu-latest
26 # This should take 1 minute at most, but let's be generous. The default of 6 hours is definitely too long.
29 # This checks out the base branch because of pull_request_target
30 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34 - name: Resolving the merge commit
36 GH_TOKEN: ${{ github.token }}
38 if mergedSha=$(base/ci/get-merge-commit.sh ${{ github.repository }} ${{ github.event.number }}); then
39 echo "Checking the merge commit $mergedSha"
40 echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
42 echo "Skipping the rest..."
45 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48 # pull_request_target checks out the base branch by default
49 ref: ${{ env.mergedSha }}
50 # Fetches the merge commit and its parents
52 - name: Checking out base branch
56 git worktree add "$base" "$(git rev-parse HEAD^1)"
57 echo "base=$base" >> "$GITHUB_ENV"
58 - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
60 - name: Fetching the pinned tool
62 # Update the pinned version using ci/nixpkgs-vet/update-pinned-tool.sh
64 # The pinned version of the tooling to use.
65 toolVersion=$(<ci/nixpkgs-vet/pinned-version.txt)
67 # Fetch the x86_64-linux-specific release artifact containing the gzipped NAR of the pre-built tool.
68 toolPath=$(curl -sSfL https://github.com/NixOS/nixpkgs-vet/releases/download/"$toolVersion"/x86_64-linux.nar.gz \
69 | gzip -cd | nix-store --import | tail -1)
71 # Adds a result symlink as a GC root.
72 nix-store --realise "$toolPath" --add-root result
73 - name: Running nixpkgs-vet
76 # Force terminal colors to be enabled. The library that `nixpkgs-vet` uses respects https://bixense.com/clicolors/
79 if result/bin/nixpkgs-vet --base "$base" .; then
83 echo "To run locally: ./ci/nixpkgs-vet.sh $GITHUB_BASE_REF https://github.com/$GITHUB_REPOSITORY.git"
84 echo "If you're having trouble, ping @NixOS/nixpkgs-vet"