Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions extra/git/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,35 @@ let
default = "";
type = types.str;
};

src = mkOption {
description = "File containing the script to install";
default = "";
type = types.str;
};
};

# Only keep all the hooks that have a value set.
hooksWithData = filterAttrs (k: v: k != "enable" && v.text != "") cfg;
hooksWithData = filterAttrs
(k: v: k != "enable"
&& (v.text != "" || v.src != "")
)
cfg;

# A collection of all the git hooks in the /bin folder
hooksDir =
let
mkHookScript = k: hook:
pkgs.runCommand k
{
text = hook.text;
text =
assert lib.assertMsg (!(hook.text != "" && hook.src != ""))
"options ${k}.text and ${k}.src are mutually exclusive";
if hook.text != ""
then hook.text
else
builtins.readFile readFile.src;

passAsFile = [ "text" ];
}
''
Expand Down