nixpkgs/pkgs/development/interpreters/ruby/ruby-2.0.0.nix

104 lines
3.6 KiB
Nix
Raw Normal View History

2015-01-24 02:20:47 +00:00
{ stdenv, lib, fetchurl, fetchFromGitHub
2013-02-25 11:16:32 +00:00
, zlib, zlibSupport ? true
, openssl, opensslSupport ? true
, gdbm, gdbmSupport ? true
2015-01-21 20:22:21 +00:00
, ncurses, readline, cursesSupport ? true
2013-02-25 11:16:32 +00:00
, groff, docSupport ? false
, libyaml, yamlSupport ? true
, libffi, fiddleSupport ? true
, ruby_2_0_0, autoreconfHook, bison, useRailsExpress ? true
2013-02-25 11:16:32 +00:00
}:
let
op = stdenv.lib.optional;
ops = stdenv.lib.optionals;
patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; };
baseruby = ruby_2_0_0.override { useRailsExpress = false; };
2013-02-25 11:16:32 +00:00
in
stdenv.mkDerivation rec {
version = with passthru; "${majorVersion}.${minorVersion}.${teenyVersion}-p${patchLevel}";
2013-02-25 11:16:32 +00:00
name = "ruby-${version}";
src = if useRailsExpress then fetchFromGitHub {
owner = "ruby";
repo = "ruby";
rev = "v2_0_0_${passthru.patchLevel}";
sha256 = "14bnas1iif2shyaz4ylb0832x96y2mda52x0v0aglkvqmcz1cfxb";
} else fetchurl {
url = "https://cache.ruby-lang.org/pub/ruby/2.0/${name}.tar.bz2";
sha256 = "1sc36qxqhziqbrvp99z4qdx9j0f8r1xhcbb6scb3m4nb02cwzk9d";
2013-02-25 11:16:32 +00:00
};
# Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
NROFF = "${groff}/bin/nroff";
buildInputs = ops useRailsExpress [ autoreconfHook bison ]
++ (op fiddleSupport libffi)
++ (ops cursesSupport [ ncurses readline ] )
2013-02-25 11:16:32 +00:00
++ (op docSupport groff )
++ (op zlibSupport zlib)
++ (op opensslSupport openssl)
++ (op gdbmSupport gdbm)
++ (op yamlSupport libyaml)
# Looks like ruby fails to build on darwin without readline even if curses
# support is not enabled, so add readline to the build inputs if curses
# support is disabled (if it's enabled, we already have it) and we're
# running on darwin
++ (op (!cursesSupport && stdenv.isDarwin) readline);
2013-02-25 11:16:32 +00:00
enableParallelBuilding = true;
patches = ops useRailsExpress [
"${patchSet}/patches/ruby/2.0.0/p${passthru.patchLevel}/railsexpress/01-zero-broken-tests.patch"
"${patchSet}/patches/ruby/2.0.0/p${passthru.patchLevel}/railsexpress/02-railsexpress-gc.patch"
"${patchSet}/patches/ruby/2.0.0/p${passthru.patchLevel}/railsexpress/03-display-more-detailed-stack-trace.patch"
"${patchSet}/patches/ruby/2.0.0/p${passthru.patchLevel}/railsexpress/04-show-full-backtrace-on-stack-overflow.patch"
];
configureFlags = ["--enable-shared" ]
++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby"
# on darwin, we have /usr/include/tk.h -- so the configure script detects
# that tk is installed
++ ( if stdenv.isDarwin then [ "--with-out-ext=tk " ] else [ ]);
2013-02-25 11:16:32 +00:00
installFlags = stdenv.lib.optionalString docSupport "install-doc";
# Bundler tries to create this directory
postInstall = ''
# 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
2015-01-24 02:20:47 +00:00
'' + lib.optionalString useRailsExpress ''
rbConfig=$(find $out/lib/ruby -name rbconfig.rb)
# Prevent the baseruby from being included in the closure.
sed -i '/^ CONFIG\["BASERUBY"\]/d' $rbConfig
sed -i "s|'--with-baseruby=${baseruby}/bin/ruby'||" $rbConfig
'';
2013-02-25 11:16:32 +00:00
meta = {
license = stdenv.lib.licenses.ruby;
2013-02-25 11:16:32 +00:00
homepage = "http://www.ruby-lang.org/en/";
description = "The Ruby language";
platforms = stdenv.lib.platforms.all;
};
passthru = rec {
majorVersion = "2";
2013-02-25 11:16:32 +00:00
minorVersion = "0";
teenyVersion = "0";
patchLevel = "645";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
2013-02-25 11:16:32 +00:00
};
}