1{ stdenv, callPackage, fetchurl, makeWrapper, jre }:
2
3let
4# The version number here is whatever is reported by the RUBY_VERSION string
5rubyVersion = callPackage ../ruby/ruby-version.nix {} "2" "3" "3" "";
6jruby = stdenv.mkDerivation rec {
7 name = "jruby-${version}";
8
9 version = "9.1.16.0";
10
11 src = fetchurl {
12 url = "https://s3.amazonaws.com/jruby.org/downloads/${version}/jruby-bin-${version}.tar.gz";
13 sha256 = "0nj8v4dcg4jj0z3fk661v6mzrgg4613xr0k9xzzsz81jkqsjnb6r";
14 };
15
16 buildInputs = [ makeWrapper ];
17
18 installPhase = ''
19 mkdir -pv $out/docs
20 mv * $out
21 rm $out/bin/*.{bat,dll,exe,sh}
22 mv $out/COPYING $out/LICENSE* $out/docs
23
24 for i in $out/bin/jruby{,.bash}; do
25 wrapProgram $i \
26 --set JAVA_HOME ${jre}
27 done
28
29 ln -s $out/bin/jruby $out/bin/ruby
30
31 # Bundler tries to create this directory
32 mkdir -pv $out/${passthru.gemPath}
33 mkdir -p $out/nix-support
34 cat > $out/nix-support/setup-hook <<EOF
35 addGemPath() {
36 addToSearchPath GEM_PATH \$1/${passthru.gemPath}
37 }
38
39 addEnvHooks "$hostOffset" addGemPath
40 EOF
41 '';
42
43 passthru = rec {
44 rubyEngine = "jruby";
45 gemPath = "lib/${rubyEngine}/gems/${rubyVersion.libDir}";
46 libPath = "lib/${rubyEngine}/${rubyVersion.libDir}";
47 };
48
49 meta = {
50 description = "Ruby interpreter written in Java";
51 homepage = http://jruby.org/;
52 license = with stdenv.lib.licenses; [ cpl10 gpl2 lgpl21 ];
53 platforms = stdenv.lib.platforms.unix;
54 };
55};
56in jruby.overrideAttrs (oldAttrs: {
57 passthru = oldAttrs.passthru // {
58 devEnv = callPackage ../ruby/dev.nix {
59 ruby = jruby;
60 };
61 };
62})