depot/nix/pkgs/copybara.nix

56 lines
1.7 KiB
Nix
Raw Normal View History

# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0
2024-04-26 17:01:33 +00:00
{ buildBazelPackage, buildFHSUserEnv, openjdk11_headless, bazel, git, mercurial, makeWrapper, fetchFromGitHub }:
let
hackedBazelTop = buildFHSUserEnv {
name = "bazel";
targetPkgs = pkgs: [
(bazel.override { enableNixHacks = true; })
openjdk11_headless
git
mercurial
];
runScript = "/bin/bazel";
};
hackedBazel = hackedBazelTop // { override = x: hackedBazelTop; };
in
2023-02-10 20:07:52 +00:00
buildBazelPackage rec {
2020-05-16 15:37:45 +00:00
name = "copybara";
version = "master";
2024-04-26 17:01:33 +00:00
bazel = hackedBazel;
2020-05-16 15:37:45 +00:00
src = ../../third_party/copybara;
2023-02-10 20:07:52 +00:00
nativeBuildInputs = [ git mercurial openjdk11_headless makeWrapper ];
2020-05-16 15:37:45 +00:00
bazelTargets = [ "//java/com/google/copybara:copybara_deploy.jar" ];
2020-05-16 15:37:45 +00:00
removeRulesCC = false;
fetchConfigured = true;
2024-04-26 17:01:33 +00:00
dontAddBazelOpts = true;
2020-05-16 15:37:45 +00:00
bazelFlags = [
"--javabase=@local_jdk//:jdk"
"--host_javabase=@local_jdk//:jdk"
2024-04-26 17:01:33 +00:00
"--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8"
"--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8"
"--define=EXECUTOR=remote"
2020-05-16 15:37:45 +00:00
];
fetchAttrs = {
2024-04-26 17:01:33 +00:00
sha256 = "sha256:0r3y4lxwf2kwdfvl5qqqr6kmc0gajsqr24fr7s3ygqjr22vn99qa";
2020-05-16 15:37:45 +00:00
preHook = ''
export COURSIER_CACHE="$(echo ''${NIX_BUILD_TOP}/tmp/coursier | sed -e 's,//,/,g')"
'';
};
buildAttrs = {
installPhase = ''
mkdir -p $out/bin $out/share/java
install -Dm755 bazel-bin/java/com/google/copybara/copybara_deploy.jar $out/share/java/copybara.jar
2023-02-10 20:07:52 +00:00
makeWrapper ${openjdk11_headless}/bin/java $out/bin/copybara \
2020-05-16 15:37:45 +00:00
--add-flags "-cp $out/share/java/copybara.jar com.google.copybara.Main"
'';
};
}