formatting: add pre-commit hook to dev shell
This commit is contained in:
@@ -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 "$@"
|
||||
'');
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user