about summary refs log tree commit diff
path: root/third_party/gerrit_plugins/builder.nix
diff options
context:
space:
mode:
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 0000000000..7676f50208
--- /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"
+    '';
+  }));
+}