about summary refs log tree commit diff
path: root/modules/services
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-05-30 13:33:07 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-04 15:26:13 -0700
commitbb013ddcd016e2836e0aac05f5317fdef23789fa (patch)
tree4718925a9338cdf1db9d39724afb9c2b91949fd9 /modules/services
parentfeat(gerrit): add secret for gerrit-hook (diff)
downloadworld-bb013ddcd016e2836e0aac05f5317fdef23789fa.tar.gz
feat(gerrit): install the gerrit hook
Create a few scripts that are used to trigger the hook when a patchset
is created.

Change-Id: Ibcfdb76b3e0ca29b9adc4c2719a8f81170818788
Reviewed-on: https://cl.fcuny.net/c/world/+/172
Reviewed-by: Franck Cuny <franck@fcuny.net>
Diffstat (limited to 'modules/services')
-rw-r--r--modules/services/gerrit/default.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/services/gerrit/default.nix b/modules/services/gerrit/default.nix
index 485bd58..a56dc7e 100644
--- a/modules/services/gerrit/default.nix
+++ b/modules/services/gerrit/default.nix
@@ -1,6 +1,17 @@
 { config, pkgs, lib, ... }:
 let
   cfg = config.my.services.gerrit;
+
+  my-gerrit-hook = name:
+    pkgs.writeShellScript "my-gerrit-hook" ''
+      exec -a ${name} ${pkgs.tools.gerrit-hook}/bin/gerrit-hook "$@"
+    '';
+
+  gerritHooks = pkgs.runCommandNoCC "gerrit-hooks" { } ''
+    mkdir -p $out
+    ln -s ${my-gerrit-hook "patchset-created"} $out/patchset-created
+  '';
+
   oauth = pkgs.fetchurl {
     url =
       "https://github.com/davido/gerrit-oauth-provider/releases/download/v3.5.1/gerrit-oauth-provider.jar";
@@ -43,6 +54,7 @@ in {
         log.jsonLogging = true;
         log.textLogging = false;
         sshd.advertisedAddress = "git.fcuny.net:29418";
+        hooks.path = "${gerritHooks}";
         cache.web_sessions.maxAge = "3 months";
         plugins.allowRemoteAdmin = false;
         change.enableAttentionSet = true;