about summary refs log tree commit diff
path: root/pkgs/development/interpreters/jruby/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/interpreters/jruby/default.nix')
-rw-r--r--pkgs/development/interpreters/jruby/default.nix37
1 files changed, 33 insertions, 4 deletions
diff --git a/pkgs/development/interpreters/jruby/default.nix b/pkgs/development/interpreters/jruby/default.nix
index 74203eca3807..0ea1bf19231f 100644
--- a/pkgs/development/interpreters/jruby/default.nix
+++ b/pkgs/development/interpreters/jruby/default.nix
@@ -1,6 +1,9 @@
-{ stdenv, fetchurl, makeWrapper, jre }:
+{ stdenv, callPackage, fetchurl, makeWrapper, jre }:
 
-stdenv.mkDerivation rec {
+let
+# The version number here is whatever is reported by the RUBY_VERSION string
+rubyVersion = callPackage ../ruby/ruby-version.nix {} "2" "3" "3" "";
+jruby = stdenv.mkDerivation rec {
   name = "jruby-${version}";
 
   version = "9.1.12.0";
@@ -18,16 +21,42 @@ stdenv.mkDerivation rec {
      rm $out/bin/*.{bat,dll,exe,sh}
      mv $out/COPYING $out/LICENSE* $out/docs
 
-     for i in $out/bin/*; do
+     for i in $out/bin/jruby{,.bash}; do
        wrapProgram $i \
          --set JAVA_HOME ${jre}
      done
+
+     ln -s $out/bin/jruby $out/bin/ruby
+
+     # Bundler tries to create this directory
+     mkdir -pv $out/${passthru.gemPath}
+     mkdir -p $out/nix-support
+     cat > $out/nix-support/setup-hook <<EOF
+       addGemPath() {
+         addToSearchPath GEM_PATH \$1/${passthru.gemPath}
+       }
+
+       envHooks+=(addGemPath)
+     EOF
   '';
 
+  passthru = rec {
+    rubyEngine = "jruby";
+    gemPath = "lib/${rubyEngine}/gems/${rubyVersion.libDir}";
+    libPath = "lib/${rubyEngine}/${rubyVersion.libDir}";
+  };
+
   meta = {
     description = "Ruby interpreter written in Java";
     homepage = http://jruby.org/;
     license = with stdenv.lib.licenses; [ cpl10 gpl2 lgpl21 ];
     platforms = stdenv.lib.platforms.unix;
   };
-}
+};
+in jruby.overrideAttrs (oldAttrs: {
+  passthru = oldAttrs.passthru // {
+    devEnv = callPackage ../ruby/dev.nix {
+      ruby = jruby;
+    };
+  };
+})