jruby: make package compatible with bundix; add devEnv

- 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.
This commit is contained in:
Alastair Pharo 2017-07-10 16:41:36 +10:00
parent 68935892ab
commit 0383c0aa6b

View File

@ -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";
@ -22,12 +25,38 @@ stdenv.mkDerivation rec {
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;
};
};
})