From 76dd430cd87c1fe9d859843c5d228abbdc7923bb Mon Sep 17 00:00:00 2001 From: Philip Potter Date: Sun, 26 Jul 2015 21:45:32 +0100 Subject: [PATCH] bazel: fix build, make compatible with openjdk Bazel 981b7bc1 depends on protobuf-2.5 and won't work with 2.6 (and in bbe84fe3d upgraded straight to protobuf 3.0.0-alpha3); this commit fixes the dependency to depend on protobuf2_5 specifically. The bazel compile.sh needs `which` on the PATH; so this commit adds that as a dependency. Setting JAVA_HOME to ${jdk} broke bazel when used with openjdk, with the message: Problem with java installation: couldn't find/access rt.jar in /nix/store/z9vc0vzyzhnpl5l5inmqdnvdnbxmmmg7-openjdk-8u60b24 This is because if you set JAVA_HOME, bazel will look for rt.jar in $JAVA_HOME/lib and $JAVA_HOME/jre/lib, but the nixpkgs openjdk distribution puts rt.jar in ${jdk}/lib/openjdk/jre/lib for some reason. To fix this, this commit uses the ${jdk.home} passthru value to use the appropriate JAVA_HOME for the given jdk. As bazel now works with openjdk, and openjdk is free while oraclejdk is not, this commit changes the default jdk for bazel to openjdk. Since this package didn't have a listed maintainer, I'm claiming it. --- pkgs/development/tools/build-managers/bazel/default.nix | 7 ++++--- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix index e9ddc17bb026..ff23390d79ca 100644 --- a/pkgs/development/tools/build-managers/bazel/default.nix +++ b/pkgs/development/tools/build-managers/bazel/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchFromGitHub, jdk, zip, zlib, protobuf, pkgconfig, libarchive, unzip, makeWrapper }: +{ stdenv, fetchFromGitHub, jdk, zip, zlib, protobuf2_5, pkgconfig, libarchive, unzip, which, makeWrapper }: stdenv.mkDerivation rec { name = "bazel-20150326.981b7bc1"; @@ -10,19 +10,20 @@ stdenv.mkDerivation rec { sha256 = "0i9gxgqhfmix7hmkb15s7h9f8ssln08pixqm26pd1d20g0kfyxj7"; }; - buildInputs = [ pkgconfig protobuf zlib zip jdk libarchive unzip makeWrapper ]; + buildInputs = [ pkgconfig protobuf2_5 zlib zip jdk libarchive unzip which makeWrapper ]; installPhase = '' PROTOC=protoc bash compile.sh mkdir -p $out/bin $out/share cp -R output $out/share/bazel ln -s $out/share/bazel/bazel $out/bin/bazel - wrapProgram $out/bin/bazel --set JAVA_HOME "${jdk}" + wrapProgram $out/bin/bazel --set JAVA_HOME "${jdk.home}" ''; meta = { homepage = http://github.com/google/bazel/; description = "Build tool that builds code quickly and reliably"; license = stdenv.lib.licenses.asl20; + maintainers = [ stdenv.lib.maintainers.philandstuff ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b8a389aa70f7..13d0e4dddbbd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5283,7 +5283,7 @@ let bam = callPackage ../development/tools/build-managers/bam {}; - bazel = callPackage ../development/tools/build-managers/bazel { jdk = oraclejdk8; }; + bazel = callPackage ../development/tools/build-managers/bazel { jdk = openjdk8; }; bin_replace_string = callPackage ../development/tools/misc/bin_replace_string { };