depot/nix/pkgs/copybara.nix

34 lines
1 KiB
Nix

{ pkgs, ... }:
pkgs.buildBazelPackage rec {
name = "copybara";
version = "master";
src = ../../third_party/copybara;
nativeBuildInputs = with pkgs; [ git mercurial jdk makeWrapper ];
bazelTarget = "//java/com/google/copybara:copybara_deploy.jar";
removeRulesCC = false;
bazelFlags = [
"--javabase=@local_jdk//:jdk"
"--host_javabase=@local_jdk//:jdk"
"--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8"
"--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8"
];
fetchAttrs = {
sha256 = "1nlkkhk7w8lnh3s416w1g1jc4qsirrgb0fggqhqamlpjr1xiv1v5";
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
makeWrapper ${pkgs.jre}/bin/java $out/bin/copybara \
--add-flags "-cp $out/share/java/copybara.jar com.google.copybara.Main"
'';
};
}