about summary refs log tree commit diff
path: root/third_party/gerrit_plugins/builder.nix
blob: 50a4e78ae7cf511eb784ed28d670c45a941187a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ depot, lib, pkgs, ... }:
{
  buildGerritBazelPlugin =
    { name
    , src
    , depsOutputHash
    , overlayPluginCmd ? ''
        cp -R "${src}" "$out/plugins/${name}"
      ''
    , postPatch ? ""
    , patches ? [ ]
    }: ((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}
      '';

      bazelTargets = [ "//plugins/${name}" ];
    }).overrideAttrs (super: {
      deps = super.deps.overrideAttrs (superDeps: {
        outputHash = depsOutputHash;
      });
      installPhase = ''
        cp "bazel-bin/plugins/${name}/${name}.jar" "$out"
      '';
      postPatch = ''
        ${super.postPatch or ""}
        pushd "plugins/${name}"
        ${lib.concatMapStringsSep "\n" (patch: ''
          patch -p1 < ${patch}
        '') patches}
        popd
        ${postPatch}
      '';
    }));
}