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" "5" "7" "";
6jruby = stdenv.mkDerivation rec {
7 pname = "jruby";
8
9 version = "9.2.13.0";
10
11 src = fetchurl {
12 url = "https://s3.amazonaws.com/jruby.org/downloads/${version}/jruby-bin-${version}.tar.gz";
13 sha256 = "0n5glz6xm3skrfihzn3g5awdxpjsqn2k8k46gv449rk2l50w5a3k";
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 = with stdenv.lib; {
50 description = "Ruby interpreter written in Java";
51 homepage = "http://jruby.org/";
52 license = with licenses; [ cpl10 gpl2 lgpl21 ];
53 platforms = platforms.unix;
54 maintainers = [ maintainers.fzakaria ];
55 };
56};
57in jruby.overrideAttrs (oldAttrs: {
58 passthru = oldAttrs.passthru // {
59 devEnv = callPackage ../ruby/dev.nix {
60 ruby = jruby;
61 };
62 };
63})