forked from the-distro/infra
Luke Granger-Brown
dd6ee53bfe
This does a bit more than advertised, since this also switches to a different set of Bazel package building infrastructure that I'm hoping will be more extensible than buildBazelPackage as it exists in nixpkgs today. In any case, the FOD here _seems_ to be much more stable than that previously produced by the old approach, but no promises :)
46 lines
982 B
Nix
46 lines
982 B
Nix
{ gerrit
|
|
, runCommandLocal
|
|
, lib
|
|
}:
|
|
|
|
{ name
|
|
, version
|
|
, src
|
|
, depsHash ? null
|
|
, overlayPluginCmd ? ''
|
|
cp -R "${src}" "$out/plugins/${name}"
|
|
echo "STABLE_BUILD_${lib.toUpper name}_LABEL v${version}-nix${if patches != [] then "-dirty" else ""}" >> $out/.version
|
|
''
|
|
, postOverlayPlugin ? ""
|
|
, postPatch ? ""
|
|
, patches ? [ ]
|
|
}: ((gerrit.override {
|
|
extraBazelPackageAttrs = (old: {
|
|
name = "${name}.jar";
|
|
|
|
src = runCommandLocal "${name}-src" { } ''
|
|
cp -R "${gerrit.src}" "$out"
|
|
chmod -R +w "$out"
|
|
${overlayPluginCmd}
|
|
${postOverlayPlugin}
|
|
'';
|
|
depsHash = (if depsHash != null then depsHash else old.depsHash);
|
|
|
|
bazelTargets = {
|
|
"//plugins/${name}" = "$out";
|
|
};
|
|
|
|
extraBuildInstall = "";
|
|
});
|
|
}).overrideAttrs (super: {
|
|
postPatch = ''
|
|
${super.postPatch or ""}
|
|
pushd "plugins/${name}"
|
|
${lib.concatMapStringsSep "\n" (patch: ''
|
|
patch -p1 < ${patch}
|
|
'') patches}
|
|
popd
|
|
${postPatch}
|
|
'';
|
|
}))
|