Skip to content

Commit 1501439

Browse files
always run git-hooks installation script to keep .pre-commit-config.yaml in sync when all hooks are disabled
1 parent 9e4003b commit 1501439

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/modules/integrations/git-hooks.nix

+22-14
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,28 @@ in
4040
description = "Integration with https://github.com/cachix/git-hooks.nix";
4141
};
4242

43-
config = lib.mkIf ((lib.filterAttrs (id: value: value.enable) cfg.hooks) != { }) {
44-
ci = [ cfg.run ];
45-
# Add the packages for any enabled hooks at the end to avoid overriding the language-defined packages.
46-
packages = lib.mkAfter ([ packageBin ] ++ (cfg.enabledPackages or [ ]));
47-
tasks = {
48-
# TODO: split installation script into status + exec
49-
"devenv:git-hooks:install" = {
50-
exec = cfg.installationScript;
51-
before = [ "devenv:enterShell" ];
43+
config = lib.mkMerge [
44+
# Always run installation script to keep .pre-commit-config.yaml in sync
45+
{
46+
tasks = {
47+
# TODO: split installation script into status + exec
48+
"devenv:git-hooks:install" = {
49+
exec = cfg.installationScript;
50+
before = [ "devenv:enterShell" ];
51+
};
5252
};
53-
"devenv:git-hooks:run" = {
54-
exec = "pre-commit run -a";
55-
before = [ "devenv:enterTest" ];
53+
}
54+
(lib.mkIf ((lib.filterAttrs (id: value: value.enable) cfg.hooks) != { }) {
55+
ci = [ cfg.run ];
56+
# Add the packages for any enabled hooks at the end to avoid overriding the language-defined packages.
57+
packages = lib.mkAfter ([ packageBin ] ++ (cfg.enabledPackages or [ ]));
58+
tasks = {
59+
"devenv:git-hooks:run" = {
60+
exec = "pre-commit run -a";
61+
before = [ "devenv:enterTest" ];
62+
};
5663
};
57-
};
58-
};
64+
})
65+
];
66+
5967
}

0 commit comments

Comments
 (0)