git: add config helper for hooks
This commit is contained in:
parent
2e41a1bab3
commit
340ec22f6f
4 changed files with 53 additions and 0 deletions
|
|
@ -201,6 +201,21 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
hooks = mkOption {
|
||||
type = types.attrsOf types.path;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
pre-commit = ./pre-commit-script;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration helper for Git hooks.
|
||||
See <link xlink:href="https://git-scm.com/docs/githooks" />
|
||||
for reference.
|
||||
'';
|
||||
};
|
||||
|
||||
iniContent = mkOption {
|
||||
type = gitIniType;
|
||||
internal = true;
|
||||
|
|
@ -449,6 +464,15 @@ in {
|
|||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.hooks != { }) {
|
||||
programs.git.iniContent = {
|
||||
core.hooksPath = let
|
||||
entries =
|
||||
mapAttrsToList (name: path: { inherit name path; }) cfg.hooks;
|
||||
in toString (pkgs.linkFarm "git-hooks" entries);
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.aliases != { }) { programs.git.iniContent.alias = cfg.aliases; })
|
||||
|
||||
(mkIf (lib.isAttrs cfg.extraConfig) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue