diff --git a/flake.nix b/flake.nix index 8ceafa6..f99f76c 100644 --- a/flake.nix +++ b/flake.nix @@ -62,6 +62,7 @@ ./flake/wrappers.nix ./flake/dev-shells.nix ./flake/formatter.nix + ./flake/checks.nix ]; }; } diff --git a/flake/checks.nix b/flake/checks.nix new file mode 100644 index 0000000..67e8063 --- /dev/null +++ b/flake/checks.nix @@ -0,0 +1,26 @@ +{ self, inputs, ... }: +{ + perSystem = + { pkgs, ... }: + { + checks = { + treefmt = (import ./treefmt.nix { inherit inputs pkgs; }).check self; + + statix = + let + statix-config = pkgs.writeText "statix.toml" '' + disabled = ["repeated_keys"] + ''; + in + pkgs.runCommand "statix" { buildInputs = [ pkgs.statix ]; } '' + statix check ${self} --config ${statix-config} + mkdir $out + ''; + + deadnix = pkgs.runCommand "deadnix" { buildInputs = [ pkgs.deadnix ]; } '' + deadnix ${self} --fail --exclude ${self}/flake/formatter.nix + mkdir $out + ''; + }; + }; +} diff --git a/flake/formatter.nix b/flake/formatter.nix index cdccc7b..1d884b7 100644 --- a/flake/formatter.nix +++ b/flake/formatter.nix @@ -3,14 +3,6 @@ perSystem = { pkgs, ... }: { - formatter = - (inputs.treefmt-nix.lib.evalModule pkgs { - projectRootFile = "flake.nix"; - programs = { - nixfmt.enable = true; - prettier.enable = true; - just.enable = true; - }; - }).config.build.wrapper; + formatter = (import ./treefmt.nix { inherit inputs pkgs; }).wrapper; }; } diff --git a/flake/treefmt.nix b/flake/treefmt.nix new file mode 100644 index 0000000..af14ed2 --- /dev/null +++ b/flake/treefmt.nix @@ -0,0 +1,9 @@ +{ inputs, pkgs, ... }: +(inputs.treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + prettier.enable = true; + just.enable = true; + }; +}).config.build diff --git a/justfile b/justfile index 10706c8..4a65232 100644 --- a/justfile +++ b/justfile @@ -22,3 +22,6 @@ update: fmt: nix fmt + +check: + nix flake check