at v192 124 lines 5.5 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, ruby_1_9_3, autoreconfHook, bison, useRailsExpress ? true 9, libiconv, libobjc 10}: 11 12let 13 op = stdenv.lib.optional; 14 ops = stdenv.lib.optionals; 15 patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; 16 baseruby = ruby_1_9_3.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 = "v1_9_3_${passthru.patchLevel}"; 28 sha256 = "1r9xzzxmci2ajb34qb4y1w424mz878zdgzxkfp9w60agldxnb36s"; 29 } else fetchurl { 30 url = "http://cache.ruby-lang.org/pub/ruby/1.9/${name}.tar.bz2"; 31 sha256 = "07kpvv2z7g6shflls7fyfga8giifahwlnl30l49qdm9i6izf7idh"; 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 ++ (ops cursesSupport [ ncurses readline ] ) 39 ++ (op docSupport groff ) 40 ++ (op zlibSupport zlib) 41 ++ (op opensslSupport openssl) 42 ++ (op gdbmSupport gdbm) 43 ++ (op yamlSupport libyaml) 44 # Looks like ruby fails to build on darwin without readline even if curses 45 # support is not enabled, so add readline to the build inputs if curses 46 # support is disabled (if it's enabled, we already have it) and we're 47 # running on darwin 48 ++ (op (!cursesSupport && stdenv.isDarwin) readline) 49 ++ (ops stdenv.isDarwin [ libiconv libobjc ]); 50 51 enableParallelBuilding = true; 52 53 patches = [ 54 ./ruby19-parallel-install.patch 55 ./bitperfect-rdoc.patch 56 ] ++ ops useRailsExpress [ 57 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/01-fix-make-clean.patch" 58 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/02-zero-broken-tests.patch" 59 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/03-railsbench-gc.patch" 60 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/04-display-more-detailed-stack-trace.patch" 61 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/05-fork-support-for-gc-logging.patch" 62 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/06-track-live-dataset-size.patch" 63 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/07-webrick_204_304_keep_alive_fix.patch" 64 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/08-export-a-few-more-symbols-for-ruby-prof.patch" 65 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/09-thread-variables.patch" 66 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/10-faster-loading.patch" 67 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/11-falcon-st-opt.patch" 68 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/12-falcon-sparse-array.patch" 69 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/13-falcon-array-queue.patch" 70 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/14-railsbench-gc-fixes.patch" 71 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/15-show-full-backtrace-on-stack-overflow.patch" 72 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/16-configurable-fiber-stack-sizes.patch" 73 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/17-backport-psych-20.patch" 74 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/18-fix-missing-c-return-event.patch" 75 "${patchSet}/patches/ruby/1.9.3/p${passthru.patchLevel}/railsexpress/19-fix-process-daemon-call.patch" 76 ]; 77 78 configureFlags = [ "--enable-shared" "--enable-pthread" ] 79 ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" 80 # on darwin, we have /usr/include/tk.h -- so the configure script detects 81 # that tk is installed 82 ++ ( if stdenv.isDarwin then [ "--with-out-ext=tk " ] else [ ]); 83 84 installFlags = stdenv.lib.optionalString docSupport "install-doc"; 85 86 CFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-mmacosx-version-min=10.7"; 87 88 postInstall = '' 89 # Bundler tries to create this directory 90 mkdir -pv $out/${passthru.gemPath} 91 mkdir -p $out/nix-support 92 cat > $out/nix-support/setup-hook <<EOF 93 addGemPath() { 94 addToSearchPath GEM_PATH \$1/${passthru.gemPath} 95 } 96 97 envHooks+=(addGemPath) 98 EOF 99 '' + lib.optionalString useRailsExpress '' 100 rbConfig=$(find $out/lib/ruby -name rbconfig.rb) 101 102 # Prevent the baseruby from being included in the closure. 103 sed -i '/^ CONFIG\["BASERUBY"\]/d' $rbConfig 104 sed -i "s|'--with-baseruby=${baseruby}/bin/ruby'||" $rbConfig 105 ''; 106 107 meta = with stdenv.lib; { 108 license = licenses.ruby; 109 homepage = "http://www.ruby-lang.org/en/"; 110 description = "The Ruby language"; 111 maintainers = with maintainers; [ lovek323 ]; 112 platforms = platforms.all; 113 }; 114 115 passthru = rec { 116 majorVersion = "1"; 117 minorVersion = "9"; 118 teenyVersion = "3"; 119 patchLevel = "551"; 120 rubyEngine = "ruby"; 121 libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}"; 122 gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}"; 123 }; 124}