diff options
author | tv <tv@krebsco.de> | 2015-11-09 19:07:26 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2015-11-09 19:07:26 +0100 |
commit | 193bb70e2ea95a56839fdd79985ed27f4962426d (patch) | |
tree | 28dab916ff9a8ed7b701a965812ccbf8747869f4 /krebs/4lib | |
parent | 1f39b86dad2f8ddeb8008f6dda02a6dea1c369a6 (diff) |
{tv => krebs} git lib & git hooks
Diffstat (limited to 'krebs/4lib')
-rw-r--r-- | krebs/4lib/default.nix | 6 | ||||
-rw-r--r-- | krebs/4lib/git.nix | 42 |
2 files changed, 46 insertions, 2 deletions
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix index 3f27ea891..1cabeae27 100644 --- a/krebs/4lib/default.nix +++ b/krebs/4lib/default.nix @@ -3,7 +3,7 @@ with builtins; with lib; -rec { +let out = rec { eq = x: y: x == y; @@ -17,6 +17,7 @@ rec { dir.has-default-nix = path: pathExists (path + "/default.nix"); dns = import ./dns.nix { inherit lib; }; + git = import ./git.nix { lib = lib // out; }; listset = import ./listset.nix { inherit lib; }; shell = import ./shell.nix { inherit lib; }; tree = import ./tree.nix { inherit lib; }; @@ -33,4 +34,5 @@ rec { mapAttrValues = f: mapAttrs (_: f); setAttr = name: value: set: set // { ${name} = value; }; -} + +}; in out diff --git a/krebs/4lib/git.nix b/krebs/4lib/git.nix new file mode 100644 index 000000000..d50ba2018 --- /dev/null +++ b/krebs/4lib/git.nix @@ -0,0 +1,42 @@ +{ lib, ... }: + +let + inherit (lib) addNames escapeShellArg makeSearchPath optionalString; + + commands = addNames { + git-receive-pack = {}; + git-upload-pack = {}; + }; + + receive-modes = addNames { + fast-forward = {}; + non-fast-forward = {}; + create = {}; + delete = {}; + merge = {}; # TODO implement in git.nix + }; + + permissions = { + fetch = { + allow-commands = [ + commands.git-upload-pack + ]; + }; + + push = ref: extra-modes: { + allow-commands = [ + commands.git-receive-pack + commands.git-upload-pack + ]; + allow-receive-ref = ref; + allow-receive-modes = [ receive-modes.fast-forward ] ++ extra-modes; + }; + }; + + refs = { + master = "refs/heads/master"; + all-heads = "refs/heads/*"; + }; + +in +commands // receive-modes // permissions // refs |