1name: Check that files are formatted
2
3on:
4 pull_request:
5 paths:
6 - .github/workflows/check-format.yml
7 pull_request_target:
8
9permissions: {}
10
11jobs:
12 nixos:
13 name: fmt-check
14 runs-on: ubuntu-24.04-arm
15 steps:
16 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17 with:
18 sparse-checkout: .github/actions
19 - name: Check if the PR can be merged and checkout the merge commit
20 uses: ./.github/actions/get-merge-commit
21 with:
22 merged-as-untrusted: true
23
24 - uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31
25 with:
26 extra_nix_config: sandbox = true
27
28 - name: Check that files are formatted
29 run: |
30 # Note that it's fine to run this on untrusted code because:
31 # - There's no secrets accessible here
32 # - The build is sandboxed
33 if ! nix-build untrusted/ci -A fmt.check; then
34 echo "Some files are not properly formatted"
35 echo "Please format them by going to the Nixpkgs root directory and running one of:"
36 echo " nix-shell --run treefmt"
37 echo " nix develop --command treefmt"
38 echo " nix fmt"
39 echo "Make sure your branch is up to date with master; rebase if not."
40 echo "If you're having trouble, please ping @NixOS/nix-formatting"
41 exit 1
42 fi