I have an interesting dilemma. I have a nix-shell that includes: jruby & openjdk8_headless.
JRuby sets the JAVA_HOME parameter to the JRE using wrapProgram.
Excerpt from pkgs/development/interpreters/jruby/default.nix
installPhase = ''
mkdir -pv $out/docs
mv * $out
rm $out/bin/*.{bat,dll,exe,sh}
mv $out/COPYING $out/LICENSE* $out/docs
for i in $out/bin/jruby{,.bash}; do
wrapProgram $i \
--set JAVA_HOME ${jre}
done
This means that if I dump out JAVA_HOME in my Ruby program I get
/nix/store/7qknskbanpwq7a71s2n6dv3l5b3frj7d-openjdk-8u242-b08-jre
puts ENV['JAVA_HOME']
However, I want to have my Ruby script invoke Gradle (gradlew); which requires the JDK.
This works through the shell directly because openjdk8_headless sets JAVA_HOME to be the JDK.
env | grep JAVA
JAVA_HOME=/nix/store/pgw9gv88j8y9wa01aj416w4m0m5mrfnr-openjdk-headless-8u242-b08/lib/openjdk
This ultimately gets squashed by the JRuby wrapProgram.
I understand that likely, I can avoid this dilemma if I’m using Gradle managed through my nix-shell; however that’s larger undertaking.
Is there a workaround solution here? Using the gradlew (Gradle wrapper script) is ideal in my setup for now.