at 15.09-beta 3.9 kB view raw
1{ stdenv, lib, fetchurl, fetchgit, fetchFromGitHub 2, zlib, zlibSupport ? true 3, openssl, opensslSupport ? true 4, gdbm, gdbmSupport ? true 5, ncurses, readline, cursesSupport ? true 6, groff, docSupport ? false 7, libyaml, yamlSupport ? true 8, libffi, fiddleSupport ? true 9, ruby_2_2_2, autoreconfHook, bison, useRailsExpress ? true 10, libiconv, libobjc, libunwind 11}: 12 13let 14 op = stdenv.lib.optional; 15 ops = stdenv.lib.optionals; 16 patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; 17 config = import ./config.nix fetchgit; 18 baseruby = ruby_2_2_2.override { useRailsExpress = false; }; 19in 20 21stdenv.mkDerivation rec { 22 version = with passthru; "${majorVersion}.${minorVersion}.${teenyVersion}-p${patchLevel}"; 23 24 name = "ruby-${version}"; 25 26 src = if useRailsExpress then fetchFromGitHub { 27 owner = "ruby"; 28 repo = "ruby"; 29 rev = "v2_2_2"; 30 sha256 = "08mw1ql2ghy483cp8xzzm78q17simn4l6phgm2gah7kjh9y3vbrn"; 31 } else fetchurl { 32 url = "http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz"; 33 sha256 = "0i4v7l8pnam0by2cza12zldlhrffqchwb2m9shlnp7j2gqqhzz2z"; 34 }; 35 36 # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds. 37 NROFF = "${groff}/bin/nroff"; 38 39 buildInputs = ops useRailsExpress [ autoreconfHook bison ] 40 ++ (op fiddleSupport libffi) 41 ++ (ops cursesSupport [ ncurses readline ]) 42 ++ (op docSupport groff) 43 ++ (op zlibSupport zlib) 44 ++ (op opensslSupport openssl) 45 ++ (op gdbmSupport gdbm) 46 ++ (op yamlSupport libyaml) 47 # Looks like ruby fails to build on darwin without readline even if curses 48 # support is not enabled, so add readline to the build inputs if curses 49 # support is disabled (if it's enabled, we already have it) and we're 50 # running on darwin 51 ++ (op (!cursesSupport && stdenv.isDarwin) readline) 52 ++ (ops stdenv.isDarwin [ libiconv libobjc libunwind ]); 53 54 enableParallelBuilding = true; 55 56 patches = ops useRailsExpress [ 57 "${patchSet}/patches/ruby/2.2.2/railsexpress/01-zero-broken-tests.patch" 58 "${patchSet}/patches/ruby/2.2.2/railsexpress/02-improve-gc-stats.patch" 59 "${patchSet}/patches/ruby/2.2.2/railsexpress/03-display-more-detailed-stack-trace.patch" 60 "${patchSet}/patches/ruby/2.2.2/railsexpress/04-backported-bugfixes-222.patch" 61 ]; 62 63 postPatch = ops useRailsExpress '' 64 sed -i configure.in -e '/config.guess/d' 65 cp ${config}/config.guess tool/ 66 cp ${config}/config.sub tool/ 67 ''; 68 69 configureFlags = ["--enable-shared" ] 70 ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" 71 # on darwin, we have /usr/include/tk.h -- so the configure script detects 72 # that tk is installed 73 ++ ( if stdenv.isDarwin then [ "--with-out-ext=tk " ] else [ ]); 74 75 installFlags = stdenv.lib.optionalString docSupport "install-doc"; 76 # Bundler tries to create this directory 77 postInstall = '' 78 # Bundler tries to create this directory 79 mkdir -pv $out/${passthru.gemPath} 80 mkdir -p $out/nix-support 81 cat > $out/nix-support/setup-hook <<EOF 82 addGemPath() { 83 addToSearchPath GEM_PATH \$1/${passthru.gemPath} 84 } 85 86 envHooks+=(addGemPath) 87 EOF 88 '' + lib.optionalString useRailsExpress '' 89 rbConfig=$(find $out/lib/ruby -name rbconfig.rb) 90 91 # Prevent the baseruby from being included in the closure. 92 sed -i '/^ CONFIG\["BASERUBY"\]/d' $rbConfig 93 sed -i "s|'--with-baseruby=${baseruby}/bin/ruby'||" $rbConfig 94 ''; 95 96 meta = { 97 license = stdenv.lib.licenses.ruby; 98 homepage = "http://www.ruby-lang.org/en/"; 99 description = "The Ruby language"; 100 platforms = stdenv.lib.platforms.all; 101 }; 102 103 passthru = rec { 104 majorVersion = "2"; 105 minorVersion = "2"; 106 teenyVersion = "2"; 107 patchLevel = "0"; 108 rubyEngine = "ruby"; 109 libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}"; 110 gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}"; 111 }; 112}