commit 40a5b953dba094e30aa2d446fa6509021d8abe48
parent 9a20743583c7a63babd6e9afed119abe5a98f188
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 27 May 2022 13:22:27 +0200
parent 9a20743583c7a63babd6e9afed119abe5a98f188
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 27 May 2022 13:22:27 +0200
machins/osterei/git: add gitolite option 'hooks.postReceive' (allows to add something to the post-receive hook from multiple places)
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/machines/osterei/git/default.nix b/machines/osterei/git/default.nix @@ -49,6 +49,9 @@ let in { + imports = [ + ./options.nix + ]; age.secrets.restic-gitolite.file = ../../../secrets/osterei/restic/gitolite.age; restic-backups.gitolite = {
diff --git a/machines/osterei/git/options.nix b/machines/osterei/git/options.nix @@ -0,0 +1,29 @@ +{ options, config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.gitolite; + +in { + + options = { + services.gitolite.hooks.postReceive = mkOption { + type = types.lines; + default = ""; + }; + }; + + config = lib.mkIf cfg.enable { + services.gitolite.commonHooks = [ "${pkgs.writeShellScriptBin "post-receive" '' + read oldrev newrev ref + [ -t 0 ] || cat >/dev/null + [ -z "$GL_REPO" ] && die GL_REPO not set + + ${cfg.hooks.postReceive} + + ''}/bin/post-receive" ]; + + }; + +}