make git-hooks opt-in

pre-commit hook break git commits and are disruptive.
Therefore people that want to enable this feature, should enable it locally instead.
I.e. treefmt will also check untracked files that are not meant for the current commit.
This commit is contained in:
Jörg Thalheim
2024-05-27 10:58:55 +02:00
parent a21e246e97
commit e23755d78e
4 changed files with 29 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
{ inputs, ... }:
{ ... }:
{
perSystem =
{
@@ -9,7 +9,6 @@
}:
let
writers = pkgs.callPackage ./pkgs/builders/script-writers.nix { };
inherit (pkgs.callPackage inputs.git-hooks { }) lib;
ansiEscapes = {
reset = ''\033[0m'';
@@ -22,11 +21,6 @@
select-shell = writers.writePython3Bin "select-shell" {
flakeIgnore = [ "E501" ];
} ./pkgs/scripts/select-shell.py;
# run treefmt before each commit
install-pre-commit-hook =
with lib.git-hooks;
pre-commit (wrap.abort-on-change config.treefmt.build.wrapper);
in
{
devShells.default = pkgs.mkShell {
@@ -41,8 +35,6 @@
config.treefmt.build.wrapper
];
shellHook = ''
${install-pre-commit-hook}
echo -e "${ansiEscapes.green}switch to another dev-shell using: select-shell${ansiEscapes.reset}"
'';
};