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

androidStudioPackages: set JAVA_HOME in wrapper to bundled version #112667

Merged
merged 1 commit into from Feb 10, 2021
Merged

androidStudioPackages: set JAVA_HOME in wrapper to bundled version #112667

merged 1 commit into from Feb 10, 2021

Conversation

ghost
Copy link

@ghost ghost commented Feb 10, 2021

Motivation for this change

Flutter applications will not build in a --pure environment without this set.
I also moved all the --set arguments to the top of the call.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@r-rmcgibbo
Copy link

Result of nixpkgs-review pr 112667 at 337aecf run on x86_64-linux 1

4 packages built:
  • android-studio (androidStudioPackages.stable)
  • androidStudioPackages.beta
  • androidStudioPackages.canary
  • androidStudioPackages.dev

@SuperSandro2000 SuperSandro2000 merged commit 758b29b into NixOS:master Feb 10, 2021
@tadfisher
Copy link
Contributor

This is an unfortunate change, because I want to build using OpenJDK 11 and I am no longer able to without setting the JDK path to the path to jdk11 in the Nix store. Before it would default to JAVA_HOME which was exactly what I wanted.

@tadfisher
Copy link
Contributor

In addition, the bundled JRE won't work outside of Studio's FHS environment, so it is much more of a hassle to use the bundled JDK on the command line.

@ghost
Copy link
Author

ghost commented Feb 24, 2021

This is an unfortunate change, because I want to build using OpenJDK 11 and I am no longer able to without setting the JDK path to the path to jdk11 in the Nix store. Before it would default to JAVA_HOME which was exactly what I wanted.

I understand the issue, but I am unsure of a solution that solves both scenarios.

  1. The user only installs android-studio and wants to run java in the built-in terminal.
  2. The user installs android-studio, and the JDK, and sets JAVA_HOME.

Looking at the .studio.sh-wrapped file, it looks like the JDK is detected through a few ways, with priority in order of

  1. $STUDIO_JDK
  2. ${XDG_CONFIG_HOME:-$HOME/.config}/Google/AndroidStudio4.1/studio.jdk
  3. (If linux) $IDE_HOME/jre{64,}
  4. $JDK_HOME
  5. $JAVA_HOME
  6. java in path

The IDE is then run with whatever JDK it found doing this, and presumably the project default is also then set using that logic.

It is not a solution in general, but would settings JDK_HOME in your environment fit your needs? If I remember correctly, android studio runs fine with openjdk 11 and 12.

@tadfisher
Copy link
Contributor

There is another solution, and that is to use --set-default in wrapProgram to avoid overwriting the environment.

@ghost
Copy link
Author

ghost commented Feb 24, 2021

You are right. I will make a merge request now.

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

4 participants