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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
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 != '' }}