about summary refs log tree commit diff
path: root/third_party/gerrit_plugins/builder.nix
diff options
context:
space:
mode:
authorLuke Granger-Brown <hg@lukegb.com>2020-07-26T12·51+0100
committerlukegb <lukegb@tvl.fyi>2020-07-27T00·00+0000
commite780435d09207b84dff49c870e875ad3f052b2fe (patch)
treebf219d90d330f186eca378ea63e7d0b88d4aed74 /third_party/gerrit_plugins/builder.nix
parent2b7fe6f95769a134f55f277f7d5575530467babd (diff)
chore(3p/gerrit_plugins): add machinery for compiling Gerrit plugins from source r/1488
This looks particularly obnoxious for the owners plugin, because it's
actually two plugins with a common library in the same repo. Other
plugins are much cleaner to deal with (hence the default for
overlayPluginCmd).

Change-Id: Ibb9588c8a29b63e8509436fcbb70054e89349712
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1461
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/gerrit_plugins/builder.nix')
-rw-r--r--third_party/gerrit_plugins/builder.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/third_party/gerrit_plugins/builder.nix b/third_party/gerrit_plugins/builder.nix
new file mode 100644
index 000000000000..7676f5020848
--- /dev/null
+++ b/third_party/gerrit_plugins/builder.nix
@@ -0,0 +1,28 @@
+{ depot, pkgs, ... }:
+{
+  buildGerritBazelPlugin = {
+    name,
+    src,
+    depsOutputHash,
+    overlayPluginCmd ? ''
+      cp -R "${src}" "$out/plugins/${name}"
+    '',
+  }: ((depot.third_party.gerrit.override {
+    name = "${name}.jar";
+
+    src = pkgs.runCommandLocal "${name}-src" {} ''
+      cp -R "${depot.third_party.gerrit.src}" "$out"
+      chmod +w "$out/plugins"
+      ${overlayPluginCmd}
+    '';
+
+    bazelTarget = "//plugins/${name}";
+  }).overrideAttrs (super: {
+    deps = super.deps.overrideAttrs (superDeps: {
+      outputHash = depsOutputHash;
+    });
+    installPhase = ''
+      cp "bazel-bin/plugins/${name}/${name}.jar" "$out"
+    '';
+  }));
+}