formatting: add pre-commit hook to dev shell

This commit is contained in:
DavHau
2023-07-28 18:12:31 +02:00
parent 461bd84205
commit cb307f761a
6 changed files with 145 additions and 5 deletions

View File

@@ -2,9 +2,14 @@
perSystem =
{ pkgs
, self'
, config
, ...
}: {
devShells.default = pkgs.mkShell {
inputsFrom = [
config.pre-commit.devShell
config.treefmt.build.devShell
];
packages = [
pkgs.tea
self'.packages.tea-create-pr

View File

@@ -3,9 +3,10 @@
, ...
}: {
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.treefmt-nix.flakeModule
];
perSystem = { pkgs, ... }: {
perSystem = { pkgs, config, ... }: {
treefmt.projectRootFile = "flake.nix";
treefmt.flakeCheck = true;
treefmt.flakeFormatter = true;
@@ -36,5 +37,16 @@
];
includes = [ "*.py" ];
};
# activated in devShells via inputsFrom = [config.pre-commit.devShell];
pre-commit.settings.hooks.format-all = {
name = "format-all";
enable = true;
pass_filenames = true;
entry = toString (pkgs.writeScript "treefmt" ''
#!${pkgs.bash}/bin/bash
${config.treefmt.build.wrapper}/bin/treefmt --clear-cache --fail-on-change "$@"
'');
};
};
}

View File

@@ -1,4 +0,0 @@
{ ... }: {
pre-commit.settings.hooks.alejandra.enable = true;
pre-commit.settings.hooks.shellcheck.enable = true;
}