1 name: "Check whether nix files are parseable"
6 # avoids approving first time contributors
13 runs-on: ubuntu-latest
14 if: "github.repository_owner == 'NixOS' && !contains(github.event.pull_request.title, '[skip treewide]')"
16 - name: Get list of changed files from PR
18 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 repos/NixOS/nixpkgs/pulls/${{github.event.number}}/files --paginate \
22 | jq --raw-output '.[] | select(.status != "removed" and (.filename | endswith(".nix"))) | .filename' \
23 > "$HOME/changed_files"
24 if [[ -s "$HOME/changed_files" ]]; then
25 echo "CHANGED_FILES=$HOME/changed_files" > "$GITHUB_ENV"
27 - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
29 # pull_request_target checks out the base branch by default
30 ref: refs/pull/${{ github.event.pull_request.number }}/merge
31 if: ${{ env.CHANGED_FILES && env.CHANGED_FILES != '' }}
32 - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
34 nix_path: nixpkgs=channel:nixpkgs-unstable
35 - name: Parse all changed or added nix files
38 while IFS= read -r file; do
39 out="$(nix-instantiate --parse "$file")" || { echo "$out" && ret=1; }
40 done < "$HOME/changed_files"
42 if: ${{ env.CHANGED_FILES && env.CHANGED_FILES != '' }}