Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying src path for git hooks #96

Closed
wants to merge 1 commit into from
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