2014-09-18 16:43:16 +01:00
|
|
|
{ stdenv, fetchurl, fetchgit, fetchFromGitHub
|
2014-08-30 12:01:02 +01:00
|
|
|
, zlib, zlibSupport ? true
|
|
|
|
, openssl, opensslSupport ? true
|
|
|
|
, gdbm, gdbmSupport ? true
|
|
|
|
, ncurses, readline, cursesSupport ? false
|
|
|
|
, groff, docSupport ? false
|
|
|
|
, libyaml, yamlSupport ? true
|
2014-10-26 04:47:48 +00:00
|
|
|
, libffi, fiddleSupport ? true
|
2014-08-09 05:00:08 +01:00
|
|
|
, ruby_2_1_2, autoreconfHook, bison, useRailsExpress ? true
|
2014-08-30 12:01:02 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
op = stdenv.lib.optional;
|
|
|
|
ops = stdenv.lib.optionals;
|
2014-08-09 05:00:08 +01:00
|
|
|
patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; };
|
2014-09-18 16:43:16 +01:00
|
|
|
config = import ./config.nix fetchgit;
|
2014-08-09 05:00:08 +01:00
|
|
|
baseruby = ruby_2_1_2.override { useRailsExpress = false; };
|
2014-08-30 12:01:02 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2014-08-09 05:00:08 +01:00
|
|
|
version = with passthru; "${majorVersion}.${minorVersion}.${teenyVersion}-p${patchLevel}";
|
|
|
|
|
|
|
|
name = "ruby-${version}";
|
|
|
|
|
|
|
|
src = if useRailsExpress then fetchFromGitHub {
|
|
|
|
owner = "ruby";
|
|
|
|
repo = "ruby";
|
|
|
|
rev = "v2_1_2";
|
|
|
|
sha256 = "14f8w3zwngnxsgigffh6h9z3ng53xq8mk126xmwrsmz9n3ypm6l0";
|
|
|
|
} else fetchurl {
|
|
|
|
url = "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz";
|
|
|
|
sha256 = "0db6krc2bd7yha8p96lcqrahjpsz7g7abhni134g708sh53n8apj";
|
2014-08-30 12:01:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
|
|
|
|
NROFF = "${groff}/bin/nroff";
|
|
|
|
|
2014-08-09 05:00:08 +01:00
|
|
|
buildInputs = ops useRailsExpress [ autoreconfHook bison ]
|
2014-10-26 04:47:48 +00:00
|
|
|
++ (op fiddleSupport libffi)
|
2014-08-09 05:00:08 +01:00
|
|
|
++ (ops cursesSupport [ ncurses readline ] )
|
2014-08-30 12:01:02 +01: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);
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2014-09-25 19:17:07 +01:00
|
|
|
# Fix a build failure on systems with nix store optimisation.
|
|
|
|
# (The build process attempted to copy file a overwriting file b, where a and
|
|
|
|
# b are hard-linked, which results in cp returning a non-zero exit code.)
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/4266
|
|
|
|
postUnpack = ''rm "$sourceRoot/enc/unicode/name2ctype.h"'';
|
|
|
|
|
2014-08-09 05:00:08 +01:00
|
|
|
patches = ops useRailsExpress [
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/01-zero-broken-tests.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/02-improve-gc-stats.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/03-display-more-detailed-stack-trace.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/04-show-full-backtrace-on-stack-overflow.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/05-fix-missing-c-return-event.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/06-backport-006e66b6680f60adfb434ee7397f0dbc77de7873.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/07-funny-falcon-stc-density.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/08-funny-falcon-stc-pool-allocation.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/09-aman-opt-aset-aref-str.patch"
|
|
|
|
"${patchSet}/patches/ruby/2.1.2/railsexpress/10-funny-falcon-method-cache.patch"
|
|
|
|
];
|
|
|
|
|
2014-09-18 16:43:16 +01:00
|
|
|
# Ruby >= 2.1.0 tries to download config.{guess,sub}
|
|
|
|
postPatch = ''
|
|
|
|
rm tool/config_files.rb
|
|
|
|
cp ${config}/config.guess tool/
|
|
|
|
cp ${config}/config.sub tool/
|
|
|
|
'';
|
|
|
|
|
2014-08-30 12:01:02 +01:00
|
|
|
configureFlags = ["--enable-shared" ]
|
2014-08-09 05:00:08 +01:00
|
|
|
++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby"
|
2014-08-30 12:01:02 +01:00
|
|
|
# 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 [ ]);
|
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
license = "Ruby";
|
|
|
|
homepage = "http://www.ruby-lang.org/en/";
|
|
|
|
description = "The Ruby language";
|
|
|
|
platforms = stdenv.lib.platforms.all;
|
|
|
|
};
|
|
|
|
|
|
|
|
passthru = rec {
|
2014-08-09 05:00:08 +01:00
|
|
|
majorVersion = "2";
|
|
|
|
minorVersion = "1";
|
|
|
|
teenyVersion = "2";
|
|
|
|
patchLevel = "353";
|
|
|
|
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
|
|
|
|
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
|
2014-08-30 12:01:02 +01:00
|
|
|
};
|
|
|
|
}
|