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