This is investigation I've done in support of
https://github.com/jruby/jruby/issues/6608 where I noticed some funky
issues with JRuby and module loading.
Looks like that JRuby expects JAVA_HOME to have a directory called
`jmod`, which is consistent with the Java Module system.
Unfortunately, the top level directory for the `jre` or `jdk` /nix/store
entry is not a valid JAVA_HOME since it is missing that directory.
Instead it's set within `lib/openjdk`, and there is a passthru variable
set accordingly.
This fixes JRuby and follows many other derivations.
A simple search in the code-base shows that there are many other
packages that suffer this same bug.
There are a variety of additional scripts that are included with the
JRuby installation that use JRuby itself.
For instance the `bin/gem` had the following contents:
```bash
❯ cat /nix/store/kglkqf56ii83yl6yrgcaj5r3s9m2fzr0-jruby-9.2.13.0/bin/gem
load File.join(File.dirname(__FILE__), 'jgem')
```
This is clearly wrong. Patchshebangs was not picking up the fix as part
of stdenv because the patch is not a build input but the final output
itself.
We have to rely on substituteInPlace so that we get the correct version.
```bash
❯ cat /nix/store/k4fnrn0dcsh2wzw81217r0ywsspb468f-jruby-9.2.13.0/bin/gem
```
There ver very many conflicts, basically all due to
name -> pname+version. Fortunately, almost everything was auto-resolved
by kdiff3, and for now I just fixed up a couple evaluation problems,
as verified by the tarball job. There might be some fallback to these
conflicts, but I believe it should be minimal.
Hydra nixpkgs: ?compare=1538299
Semi-automatic update generated by https://github.com/ryantm/nixpkgs-update tools.
This update was made based on information from https://repology.org/metapackage/jruby/versions.
These checks were done:
- built on NixOS
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/rake had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/ast had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/jgem had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/jirb had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/jirb_swing had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/gem had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/ri had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/irb had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/testrb had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/rdoc had a zero exit code or showed the expected version
- Warning: no invocation of /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/jrubyc had a zero exit code or showed the expected version
- /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/jruby passed the binary check.
- /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/jruby.bash passed the binary check.
- /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/ruby passed the binary check.
- /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/.jruby-wrapped passed the binary check.
- /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0/bin/.jruby.bash-wrapped passed the binary check.
- 5 of 16 passed binary check by having a zero exit code.
- 0 of 16 passed binary check by having the new version present in output.
- found 9.2.0.0 with grep in /nix/store/mxi03kwk4c23xpfjpqv1ggfkyf50wjkn-jruby-9.2.0.0
- directory tree listing: https://gist.github.com/4fecc39e96054dd41278b1d505cdb498
- du listing: https://gist.github.com/6382ad0545e74f9ff62a410b61801232
Semi-automatic update generated by https://github.com/ryantm/nixpkgs-update tools.
This update was made based on information from https://repology.org/metapackage/jruby/versions.
These checks were done:
- built on NixOS
- ran ‘/nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0/bin/jruby -h’ got 0 exit code
- ran ‘/nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0/bin/jruby --help’ got 0 exit code
- ran ‘/nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0/bin/jruby.bash -h’ got 0 exit code
- ran ‘/nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0/bin/jruby.bash --help’ got 0 exit code
- ran ‘/nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0/bin/ruby -h’ got 0 exit code
- ran ‘/nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0/bin/ruby --help’ got 0 exit code
- found 9.1.17.0 with grep in /nix/store/g4a83h4462412zd3cf95j5ny19bxgha6-jruby-9.1.17.0
- directory tree listing: https://gist.github.com/20468ca63db765e0d42a1c93191f0901
Semi-automatic update. These checks were performed:
- built on NixOS
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby -h` got 0 exit code
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby --help` got 0 exit code
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby -v` and found version 9.1.16.0
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby --version` and found version 9.1.16.0
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby.bash -h` got 0 exit code
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby.bash --help` got 0 exit code
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby.bash -v` and found version 9.1.16.0
- ran `/nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0/bin/jruby.bash --version` and found version 9.1.16.0
- found 9.1.16.0 with grep in /nix/store/yxs5d6pasfvp6000pm1sqhj89iirj3mv-jruby-9.1.16.0
- Adds the necessary passthru vars for bundler, bundix, etc. to accept
the package as a ruby.
- Adds the devEnv attribute, so that jruby.devEnv can be used to get
an environment with bundler and bundix installed.
Other executables all invoke jruby, and so don't need to be wrapped.
In some cases wrapping breaks the executables because one file is a ruby
script that directly loads the other (e.g. `gem` is a wrapper that loads
`jgem`). In this case, if the latter script has been wrapped by nix,
loading will fail.