From 757d5e746ab529980bca26093680a327c4a051d9 Mon Sep 17 00:00:00 2001 From: Brian McGee Date: Wed, 1 May 2024 09:12:01 +0100 Subject: [PATCH] feat: configure a pipeline for formatting nix code Relies on a fork of treefmt-nix until it can be merged. Signed-off-by: Brian McGee --- flake.lock | 11 ++++++----- flake.nix | 3 ++- nix/treefmt.nix | 45 +++++++++++++++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 70c5801..8451813 100644 --- a/flake.lock +++ b/flake.lock @@ -208,15 +208,16 @@ ] }, "locked": { - "lastModified": 1707300477, - "narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=", - "owner": "numtide", + "lastModified": 1714382886, + "narHash": "sha256-+gooxbbYcP+MORKQ7W/C2ATvlonW+dyHgCUPnu5dfco=", + "owner": "brianmcgee", "repo": "treefmt-nix", - "rev": "ac599dab59a66304eb511af07b3883114f061b9d", + "rev": "535e6904c34964ce56d8c092835c11fe6341acc8", "type": "github" }, "original": { - "owner": "numtide", + "owner": "brianmcgee", + "ref": "feat/pipelines", "repo": "treefmt-nix", "type": "github" } diff --git a/flake.nix b/flake.nix index 3fc06af..fb7511e 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,8 @@ flake-parts.url = "github:hercules-ci/flake-parts"; flake-root.url = "github:srid/flake-root"; treefmt-nix = { - url = "github:numtide/treefmt-nix"; + # todo switch back to numtide/treefmt-nix once merged + url = "github:brianmcgee/treefmt-nix/feat/pipelines"; inputs.nixpkgs.follows = "nixpkgs"; }; devshell = { diff --git a/nix/treefmt.nix b/nix/treefmt.nix index 66022ac..698b459 100644 --- a/nix/treefmt.nix +++ b/nix/treefmt.nix @@ -22,20 +22,37 @@ statix.enable = true; }; - settings.formatter.prettier = { - options = ["--tab-width" "4"]; - includes = [ - "*.css" - "*.html" - "*.js" - "*.json" - "*.jsx" - "*.md" - "*.mdx" - "*.scss" - "*.ts" - "*.yaml" - ]; + settings.formatter = { + deadnix = { + pipeline = "nix"; + priority = 1; + }; + + statix = { + pipeline = "nix"; + priority = 2; + }; + + alejandra = { + pipeline = "nix"; + priority = 3; + }; + + prettier = { + options = ["--tab-width" "4"]; + includes = [ + "*.css" + "*.html" + "*.js" + "*.json" + "*.jsx" + "*.md" + "*.mdx" + "*.scss" + "*.ts" + "*.yaml" + ]; + }; }; };