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 postFixup = ''
44 PATH=$out/bin:$PATH patchShebangs $out/bin
45 '';
46
47 passthru = rec {
48 rubyEngine = "jruby";
49 gemPath = "lib/${rubyEngine}/gems/${rubyVersion.libDir}";
50 libPath = "lib/${rubyEngine}/${rubyVersion.libDir}";
51 };
52
53 meta = with stdenv.lib; {
54 description = "Ruby interpreter written in Java";
55 homepage = "http://jruby.org/";
56 license = with licenses; [ cpl10 gpl2 lgpl21 ];
57 platforms = platforms.unix;
58 maintainers = [ maintainers.fzakaria ];
59 };
60};
61in jruby.overrideAttrs (oldAttrs: {
62 passthru = oldAttrs.passthru // {
63 devEnv = callPackage ../ruby/dev.nix {
64 ruby = jruby;
65 };
66 };
67})