Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel: add bazel_jdk10 variant #46465

Merged
merged 1 commit into from Sep 10, 2018
Merged

bazel: add bazel_jdk10 variant #46465

merged 1 commit into from Sep 10, 2018

Conversation

uri-canva
Copy link
Contributor

@uri-canva uri-canva commented Sep 10, 2018

Motivation for this change

To build Java 10 projects with Bazel, it needs to run with Java 10, but Bazel itself can only be built with Java 8.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@uri-canva
Copy link
Contributor Author

Verified the bazel derivation matches the existing one, only bazel_jdk10 is different.

@@ -3,7 +3,7 @@
, which, python, perl, gnused, gnugrep, findutils
# Always assume all markers valid (don't redownload dependencies).
# Also, don't clean up environment variables.
, enableNixHacks ? false
, enableNixHacks ? false, build_jdk ? jdk, run_jdk ? jdk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jdk stuff should go to a newline to not be confused the comment above.
I think camel case is more commonly used for parameters that are meant to be overridden:
buildJdk and runJdk - then the it is less likely to collide with existing package names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Reordered the lines and added a comment to make it clearer which are the straightforward dependencies being passed in and which are parameters to change the output of the derivation.

@@ -190,7 +192,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/bin
mv output/bazel $out/bin
wrapProgram "$out/bin/bazel" --set JAVA_HOME "${jdk}"
wrapProgram "$out/bin/bazel" --set JAVA_HOME "${runJdk}"
Copy link
Member

@Mic92 Mic92 Sep 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you should use --set-default here? Then every user could also just set JAVA_HOME instead of having to compile there own bazel version (for example oraclejdk).

Copy link
Member

@Mic92 Mic92 Sep 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAVA_HOME is also set by the nix-shell itself:

$ nix-shell -p jdk --command 'echo $JAVA_HOME'
/nix/store/6ickqcxhghnlabk0hfzkmlz8za945dk3-openjdk-8u181b13/lib/openjdk
nix-shell -p jdk10 --command 'echo $JAVA_HOME'
these paths will be fetched (193.76 MiB download, 457.07 MiB unpacked):
  /nix/store/d13mqf9gqqs52c8wv4s07rczvn3iqh46-openjdk-10.0.2-b13-jre
  /nix/store/wdm57lny0nwhwfgwk0rgv6d606bv9m1d-openjdk-10.0.2-b13
copying path '/nix/store/d13mqf9gqqs52c8wv4s07rczvn3iqh46-openjdk-10.0.2-b13-jre' from 'https://cache.nixos.org'...
copying path '/nix/store/wdm57lny0nwhwfgwk0rgv6d606bv9m1d-openjdk-10.0.2-b13' from 'https://cache.nixos.org'...
bash: /run/user/1000/env-vars: cannot overwrite existing file
/nix/store/wdm57lny0nwhwfgwk0rgv6d606bv9m1d-openjdk-10.0.2-b13/lib/openjdk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of other derivations using this pattern, I think it's intentional to make them use the Nix jdk / jre instead of the system installed one: JAVA_HOME tends to be set in many users' shell and they expect Nix packages to use the dependencies from Nix and not from their system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the point of view of using Nix as a package manager through profiles, rather than using nix-shell or NixOS.

@Mic92 Mic92 merged commit 2d4dcef into NixOS:master Sep 10, 2018
@uri-canva uri-canva deleted the bazel-jdk10 branch October 15, 2018 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants