From affdc02afe8f8070c8cbc7a66f5fdbbd4b29e236 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Wed, 8 May 2024 14:05:41 +0200 Subject: [PATCH] style: check formatting using nixpkgs standard and fail early in CI to enforce it --- .forgejo/workflows/check.yml | 4 ++++ treefmt.toml | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 treefmt.toml diff --git a/.forgejo/workflows/check.yml b/.forgejo/workflows/check.yml index 0968832..5d03cdc 100644 --- a/.forgejo/workflows/check.yml +++ b/.forgejo/workflows/check.yml @@ -46,6 +46,10 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' useDaemon: false + - name: Check formatting + run: | + nix --accept-flake-config --access-tokens '' develop --command treefmt --fail-on-change + - name: Run flake checks run: | # Prevent cache garbage collection by creating GC roots diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..0186e6a --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,24 @@ +[formatter.nix] +command = "nix" +options = ["fmt"] +includes = ["*.nix"] +excludes = [] + +[formatter.prettier] +command = "prettier" +options = ["--write"] +includes = [ + "*.json", + "*.yaml", + "*.md", +] + +[formatter.shell] +command = "shfmt" +options = [ + "-s", + "-w", + "-i", + "2", +] +includes = ["*.sh"]