From 6dfe6692c0f9fa96aa554d7659217696edf499c1 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 26 Sep 2023 13:05:50 +1300 Subject: [PATCH] refactor: Pull `jq` filter into a file and format it Makes the filter much easier to read, now that it's getting more complex. --- .github/workflows/ci.yml | 2 +- overrides/sort-build-systems.jq | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 overrides/sort-build-systems.jq diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05f1d5b09..98613ab3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: nix_path: nixpkgs=channel:nixos-unstable - uses: actions/checkout@v3 - name: Check format - run: nix-shell --packages jq --pure --run 'diff --unified overrides/build-systems.json <(jq --raw-output --sort-keys ".[] |= sort_by(if type==\"string\" then . else .from != null end)" < overrides/build-systems.json)' + run: nix-shell --packages jq --pure --run 'diff --unified overrides/build-systems.json <(jq --from-file overrides/sort-build-systems.jq --raw-output --sort-keys < overrides/build-systems.json)' nixpkgs-fmt: runs-on: ubuntu-latest diff --git a/overrides/sort-build-systems.jq b/overrides/sort-build-systems.jq new file mode 100644 index 000000000..5e90d4489 --- /dev/null +++ b/overrides/sort-build-systems.jq @@ -0,0 +1,8 @@ +.[] |= sort_by( + if type == "string" + then + . + else + .from != null + end +)