diff --git a/.github/workflows/check-nix-format.yml b/.github/workflows/check-format.yml similarity index 80% rename from .github/workflows/check-nix-format.yml rename to .github/workflows/check-format.yml index 8c35196e4944..ca3da602575b 100644 --- a/.github/workflows/check-nix-format.yml +++ b/.github/workflows/check-format.yml @@ -1,7 +1,4 @@ -# NOTE: Formatting with the RFC-style nixfmt command is not yet stable. -# See https://github.com/NixOS/rfcs/pull/166. - -name: Check that Nix files are formatted +name: Check that files are formatted on: pull_request_target: @@ -14,7 +11,7 @@ jobs: uses: ./.github/workflows/get-merge-commit.yml nixos: - name: nixfmt-check + name: fmt-check runs-on: ubuntu-24.04 needs: get-merge-commit if: needs.get-merge-commit.outputs.mergedSha @@ -27,13 +24,13 @@ jobs: with: extra_nix_config: sandbox = true - - name: Check that Nix files are formatted + - name: Check that files are formatted run: | # Note that it's fine to run this on untrusted code because: # - There's no secrets accessible here # - The build is sandboxed if ! nix-build ci -A fmt.check; then - echo "Some Nix files are not properly formatted" + echo "Some files are not properly formatted" echo "Please format them by going to the Nixpkgs root directory and running one of:" echo " nix-shell --run treefmt" echo " nix develop --command treefmt" diff --git a/.github/workflows/editorconfig-v2.yml b/.github/workflows/editorconfig-v2.yml deleted file mode 100644 index 68d780f2190f..000000000000 --- a/.github/workflows/editorconfig-v2.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Checking EditorConfig v2" - -on: - pull_request_target: - -permissions: {} - -jobs: - get-merge-commit: - uses: ./.github/workflows/get-merge-commit.yml - - tests: - name: editorconfig-check - runs-on: ubuntu-24.04 - needs: get-merge-commit - if: "needs.get-merge-commit.outputs.mergedSha && !contains(github.event.pull_request.title, '[skip treewide]')" - steps: - - name: Get list of changed files from PR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh api \ - repos/${{ github.repository }}/pulls/${{ github.event.number }}/files --paginate \ - | jq '.[] | select(.status != "removed") | .filename' \ - > "$HOME/changed_files" - - - name: print list of changed files - run: | - cat "$HOME/changed_files" - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - ref: ${{ needs.get-merge-commit.outputs.mergedSha }} - - - name: Get Nixpkgs revision for editorconfig-checker - run: | - # Pin to a commit from nixpkgs-unstable to avoid building from e.g. staging. - # This should not be a URL, because it would allow PRs to run arbitrary code in CI! - rev=$(jq -r .rev ci/pinned-nixpkgs.json) - echo "url=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz" >> "$GITHUB_ENV" - - - uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31 - with: - nix_path: nixpkgs=${{ env.url }} - - - name: Checking EditorConfig - run: | - < "$HOME/changed_files" nix-shell -p editorconfig-checker --run 'xargs -r editorconfig-checker -disable-indent-size' - - - if: ${{ failure() }} - run: | - echo "::error :: Hey! It looks like your changes don't follow our editorconfig settings. Read https://editorconfig.org/#download to configure your editor so you never see this error again." diff --git a/ci/OWNERS b/ci/OWNERS index 13b5c0ac4f0a..69a122d537e7 100644 --- a/ci/OWNERS +++ b/ci/OWNERS @@ -16,7 +16,7 @@ # CI /.github/*_TEMPLATE* @SigmaSquadron /.github/workflows @NixOS/Security @Mic92 @zowoq @infinisil @azuwis @wolfgangwalther -/.github/workflows/check-nix-format.yml @infinisil @wolfgangwalther +/.github/workflows/check-format.yml @infinisil @wolfgangwalther /.github/workflows/codeowners-v2.yml @infinisil @wolfgangwalther /.github/workflows/nixpkgs-vet.yml @infinisil @philiptaron @wolfgangwalther /ci @infinisil @philiptaron @NixOS/Security @wolfgangwalther diff --git a/ci/default.nix b/ci/default.nix index 67f59d61bfd4..59fb1b48574c 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -48,6 +48,13 @@ let # the default formatter for Nix code. # See https://github.com/NixOS/nixfmt programs.nixfmt.enable = true; + + settings.formatter.editorconfig-checker = { + command = "${pkgs.lib.getExe pkgs.editorconfig-checker}"; + options = [ "-disable-indent-size" ]; + includes = [ "*" ]; + priority = 1; + }; }; fs = pkgs.lib.fileset; nixFilesSrc = fs.toSource {