From dcf933e258dc5d27d4fa9002ebc1bb054009a1a2 Mon Sep 17 00:00:00 2001 From: Jude Taylor Date: Fri, 11 Sep 2015 23:46:45 -0700 Subject: [PATCH 1/4] move rubies into a single file --- .../development/interpreters/ruby/default.nix | 239 ++++++++++++++++++ .../interpreters/ruby/patchsets.nix | 126 +++++++++ .../interpreters/ruby/ruby-1.8.7.nix | 104 -------- .../interpreters/ruby/ruby-1.9.3.nix | 124 --------- .../interpreters/ruby/ruby-2.0.0.nix | 103 -------- .../interpreters/ruby/ruby-2.1.0.nix | 120 --------- .../interpreters/ruby/ruby-2.1.1.nix | 118 --------- .../interpreters/ruby/ruby-2.1.2.nix | 117 --------- .../interpreters/ruby/ruby-2.1.3.nix | 121 --------- .../interpreters/ruby/ruby-2.1.6.nix | 124 --------- .../interpreters/ruby/ruby-2.2.0.nix | 113 --------- .../interpreters/ruby/ruby-2.2.2.nix | 112 -------- pkgs/top-level/all-packages.nix | 25 +- 13 files changed, 372 insertions(+), 1174 deletions(-) create mode 100644 pkgs/development/interpreters/ruby/default.nix create mode 100644 pkgs/development/interpreters/ruby/patchsets.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-1.8.7.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-1.9.3.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.0.0.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.1.0.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.1.1.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.1.2.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.1.3.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.1.6.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.2.0.nix delete mode 100644 pkgs/development/interpreters/ruby/ruby-2.2.2.nix diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix new file mode 100644 index 00000000000..d69a1394a60 --- /dev/null +++ b/pkgs/development/interpreters/ruby/default.nix @@ -0,0 +1,239 @@ +{ stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub +, zlib, zlibSupport ? true +, openssl, opensslSupport ? true +, gdbm, gdbmSupport ? true +, ncurses, readline, cursesSupport ? true +, groff, docSupport ? false +, libyaml, yamlSupport ? true +, libffi, fiddleSupport ? true +, autoreconfHook, bison +, darwin ? null +}: + +let + op = stdenv.lib.optional; + ops = stdenv.lib.optionals; + opString = stdenv.lib.optionalString; + patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; + config = import ./config.nix { inherit fetchFromSavannah; }; + generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 } @ args: + let + versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; + isRuby21 = majorVersion == "2" && minorVersion == "1"; + baseruby = self false; + self = useRailsExpress: stdenv.mkDerivation rec { + version = "${versionNoPatch}-p${patchLevel}"; + + name = "ruby-${version}"; + + src = let + versionName = if patchLevel != "0" && stdenv.lib.versionOlder versionNoPatch "2.1" + then version + else versionNoPatch; + tag = "v" + stdenv.lib.replaceChars ["." "p" "-"] ["_" "_" ""] versionName; + in if useRailsExpress then fetchFromGitHub { + owner = "ruby"; + repo = "ruby"; + rev = tag; + sha256 = args.sha256.git; + } else fetchurl { + url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${versionName}.tar.gz"; + sha256 = args.sha256.src; + }; + + # 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 ]) + ++ (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) + ++ (ops stdenv.isDarwin (with darwin; [ libiconv libobjc libunwind ])); + + enableParallelBuilding = true; + + patches = let patchsets = import ./patchsets.nix { + inherit patchSet useRailsExpress ops patchLevel; + }; in patchsets."${versionNoPatch}"; + + postUnpack = opString isRuby21 '' + rm "$sourceRoot/enc/unicode/name2ctype.h" + ''; + + postPatch = if isRuby21 then '' + rm tool/config_files.rb + cp ${config}/config.guess tool/ + cp ${config}/config.sub tool/ + '' else opString useRailsExpress '' + sed -i configure.in -e '/config.guess/d' + cp ${config}/config.guess tool/ + cp ${config}/config.sub tool/ + ''; + + configureFlags = ["--enable-shared"] + ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" + ++ ops stdenv.isDarwin [ + # on darwin, we have /usr/include/tk.h -- so the configure script detects + # that tk is installed + "--with-out-ext=tk" + # on yosemite, "generating encdb.h" will hang for a very long time without this flag + "--with-setjmp-type=setjmp" + ]; + + 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 < $out/nix-support/setup-hook < $out/nix-support/setup-hook < $out/nix-support/setup-hook <= 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/ - ''; - - 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 [ ]); - - 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 <= 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/ - ''; - - 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 [ ]); - - 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 <= 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/ - ''; - - 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 [ ]); - - 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 <= 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/ - ''; - - 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 [ ]); - - 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 <= 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/ - ''; - - 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 [ ]); - - 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 < $out/nix-support/setup-hook < $out/nix-support/setup-hook < Date: Sat, 12 Sep 2015 11:58:02 -0700 Subject: [PATCH 2/4] put all rubies in scope --- .../development/interpreters/ruby/default.nix | 16 +-- .../interpreters/ruby/ruby-1.8.7.nix | 104 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 15 +-- 3 files changed, 121 insertions(+), 14 deletions(-) create mode 100644 pkgs/development/interpreters/ruby/ruby-1.8.7.nix diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index d69a1394a60..fa16352162c 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -6,7 +6,7 @@ , groff, docSupport ? false , libyaml, yamlSupport ? true , libffi, fiddleSupport ? true -, autoreconfHook, bison +, autoreconfHook, bison, autoconf , darwin ? null }: @@ -20,6 +20,7 @@ let let versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; isRuby21 = majorVersion == "2" && minorVersion == "1"; + isRuby18 = majorVersion == "1" && minorVersion == "8"; baseruby = self false; self = useRailsExpress: stdenv.mkDerivation rec { version = "${versionNoPatch}-p${patchLevel}"; @@ -57,19 +58,20 @@ let # support is disabled (if it's enabled, we already have it) and we're # running on darwin ++ (op (!cursesSupport && stdenv.isDarwin) readline) - ++ (ops stdenv.isDarwin (with darwin; [ libiconv libobjc libunwind ])); + ++ (ops stdenv.isDarwin (with darwin; [ libiconv libobjc libunwind ])) + ++ op isRuby18 autoconf; enableParallelBuilding = true; - patches = let patchsets = import ./patchsets.nix { + patches = (import ./patchsets.nix { inherit patchSet useRailsExpress ops patchLevel; - }; in patchsets."${versionNoPatch}"; + })."${versionNoPatch}"; postUnpack = opString isRuby21 '' rm "$sourceRoot/enc/unicode/name2ctype.h" ''; - postPatch = if isRuby21 then '' + postPatch = opString (!isRuby18) (if isRuby21 then '' rm tool/config_files.rb cp ${config}/config.guess tool/ cp ${config}/config.sub tool/ @@ -77,9 +79,9 @@ let sed -i configure.in -e '/config.guess/d' cp ${config}/config.guess tool/ cp ${config}/config.sub tool/ - ''; + ''); - configureFlags = ["--enable-shared"] + configureFlags = ["--enable-shared" "--enable-pthread"] ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" ++ ops stdenv.isDarwin [ # on darwin, we have /usr/include/tk.h -- so the configure script detects diff --git a/pkgs/development/interpreters/ruby/ruby-1.8.7.nix b/pkgs/development/interpreters/ruby/ruby-1.8.7.nix new file mode 100644 index 00000000000..0ae1d1261ee --- /dev/null +++ b/pkgs/development/interpreters/ruby/ruby-1.8.7.nix @@ -0,0 +1,104 @@ +{ stdenv, lib, fetchurl, fetchFromGitHub +, zlib, zlibSupport ? true +, openssl, opensslSupport ? true +, gdbm, gdbmSupport ? true +, ncurses, readline, cursesSupport ? true +, groff, docSupport ? false +, ruby_1_8_7, autoreconfHook, bison, useRailsExpress ? true +}: + +let + op = stdenv.lib.optional; + ops = stdenv.lib.optionals; + patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; + baseruby = ruby_1_8_7.override { useRailsExpress = false; }; +in + +stdenv.mkDerivation rec { + version = with passthru; "${majorVersion}.${minorVersion}.${teenyVersion}-p${patchLevel}"; + + name = "ruby-${version}"; + + src = if useRailsExpress then fetchFromGitHub { + owner = "ruby"; + repo = "ruby"; + rev = "v1_8_7_${passthru.patchLevel}"; + sha256 = "1xddhxr0j26hpxfixvhqdscwk2ri846w2129fcfwfjzvy19igswx"; + } else fetchurl { + url = "http://cache.ruby-lang.org/pub/ruby/1.8/${name}.tar.bz2"; + sha256 = "1qq7khilwkayrhwmzlxk83scrmiqfi7lgsn4c63znyvz2c1lgqxl"; + }; + + # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds. + NROFF = "${groff}/bin/nroff"; + + buildInputs = ops useRailsExpress [ autoreconfHook bison ] + ++ (ops cursesSupport [ ncurses readline ] ) + ++ (op docSupport groff ) + ++ (op zlibSupport zlib) + ++ (op opensslSupport openssl) + ++ (op gdbmSupport gdbm); + + patches = ops useRailsExpress [ + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/01-ignore-generated-files.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/02-fix-tests-for-osx.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/03-sigvtalrm-fix.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/04-railsbench-gc-patch.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/05-display-full-stack-trace.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/06-better-source-file-tracing.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/07-heap-dump-support.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/08-fork-support-for-gc-logging.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/09-track-malloc-size.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/10-track-object-allocation.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/11-expose-heap-slots.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/12-fix-heap-size-growth-logic.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/13-heap-slot-size.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/14-add-trace-stats-enabled-methods.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/15-track-live-dataset-size.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/16-add-object-size-information-to-heap-dump.patch" + "${patchSet}/patches/ruby/1.8.7/p374/railsexpress/17-caller-for-all-threads.patch" + ]; + + configureFlags = [ "--enable-shared" "--enable-pthread" ] + # Without this fails due to not finding X11/Xlib.h + # Not sure why this isn't required on Linux + ++ ops stdenv.isDarwin [ "--without-tcl" "--without-tk" ] + ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby"; + + installFlags = stdenv.lib.optionalString docSupport "install-doc"; + + postInstall = '' + # Bundler tries to create this directory + mkdir -pv $out/${passthru.gemPath} + mkdir -p $out/nix-support + cat > $out/nix-support/setup-hook < Date: Sat, 12 Sep 2015 22:29:26 -0700 Subject: [PATCH 3/4] re-indent; make rubies overridable --- .../development/interpreters/ruby/default.nix | 65 ++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index fa16352162c..e4065a2bfe0 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -1,14 +1,7 @@ { stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub -, zlib, zlibSupport ? true -, openssl, opensslSupport ? true -, gdbm, gdbmSupport ? true -, ncurses, readline, cursesSupport ? true -, groff, docSupport ? false -, libyaml, yamlSupport ? true -, libffi, fiddleSupport ? true -, autoreconfHook, bison, autoconf -, darwin ? null -}: +, zlib, openssl, gdbm, ncurses, readline, groff, libyaml, libffi, autoreconfHook, bison +, autoconf, darwin ? null +} @ args: let op = stdenv.lib.optional; @@ -16,30 +9,43 @@ let opString = stdenv.lib.optionalString; patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; config = import ./config.nix { inherit fetchFromSavannah; }; - generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 } @ args: - let - versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; - isRuby21 = majorVersion == "2" && minorVersion == "1"; - isRuby18 = majorVersion == "1" && minorVersion == "8"; - baseruby = self false; - self = useRailsExpress: stdenv.mkDerivation rec { - version = "${versionNoPatch}-p${patchLevel}"; + +generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 }: let + versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; + version = "${versionNoPatch}-p${patchLevel}"; + fullVersionName = if patchLevel != "0" && stdenv.lib.versionOlder versionNoPatch "2.1" + then version + else versionNoPatch; + tag = "v" + stdenv.lib.replaceChars ["." "p" "-"] ["_" "_" ""] fullVersionName; + isRuby21 = majorVersion == "2" && minorVersion == "1"; + isRuby18 = majorVersion == "1" && minorVersion == "8"; + baseruby = self.override { useRailsExpress = false; }; + self = lib.makeOverridable ( + { stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub + , useRailsExpress ? true + , zlib, zlibSupport ? true + , openssl, opensslSupport ? true + , gdbm, gdbmSupport ? true + , ncurses, readline, cursesSupport ? true + , groff, docSupport ? false + , libyaml, yamlSupport ? true + , libffi, fiddleSupport ? true + , autoreconfHook, bison, autoconf + , darwin ? null + }: + stdenv.mkDerivation rec { + inherit version; name = "ruby-${version}"; - src = let - versionName = if patchLevel != "0" && stdenv.lib.versionOlder versionNoPatch "2.1" - then version - else versionNoPatch; - tag = "v" + stdenv.lib.replaceChars ["." "p" "-"] ["_" "_" ""] versionName; - in if useRailsExpress then fetchFromGitHub { + src = if useRailsExpress then fetchFromGitHub { owner = "ruby"; repo = "ruby"; rev = tag; - sha256 = args.sha256.git; + sha256 = sha256.git; } else fetchurl { - url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${versionName}.tar.gz"; - sha256 = args.sha256.src; + url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${fullVersionName}.tar.gz"; + sha256 = sha256.src; }; # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds. @@ -104,7 +110,7 @@ let envHooks+=(addGemPath) EOF - '' + lib.optionalString useRailsExpress '' + '' + opString useRailsExpress '' rbConfig=$(find $out/lib/ruby -name rbconfig.rb) # Prevent the baseruby from being included in the closure. @@ -126,7 +132,8 @@ let libPath = "lib/${versionNoPatch}"; gemPath = "lib/${rubyEngine}/gems/${versionNoPatch}"; }; - }; in self true; + } + ) args; in self; in { ruby_1_8_7 = generic { From 68e802c46b0af8e648ffbcda853a8134ce765e23 Mon Sep 17 00:00:00 2001 From: Jude Taylor Date: Sat, 26 Sep 2015 06:23:25 -0700 Subject: [PATCH 4/4] PR comments --- .../development/interpreters/ruby/default.nix | 218 +++++++++--------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index e4065a2bfe0..89e0016f98d 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -10,130 +10,130 @@ let patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; config = import ./config.nix { inherit fetchFromSavannah; }; -generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 }: let - versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; - version = "${versionNoPatch}-p${patchLevel}"; - fullVersionName = if patchLevel != "0" && stdenv.lib.versionOlder versionNoPatch "2.1" - then version - else versionNoPatch; - tag = "v" + stdenv.lib.replaceChars ["." "p" "-"] ["_" "_" ""] fullVersionName; - isRuby21 = majorVersion == "2" && minorVersion == "1"; - isRuby18 = majorVersion == "1" && minorVersion == "8"; - baseruby = self.override { useRailsExpress = false; }; - self = lib.makeOverridable ( - { stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub - , useRailsExpress ? true - , zlib, zlibSupport ? true - , openssl, opensslSupport ? true - , gdbm, gdbmSupport ? true - , ncurses, readline, cursesSupport ? true - , groff, docSupport ? false - , libyaml, yamlSupport ? true - , libffi, fiddleSupport ? true - , autoreconfHook, bison, autoconf - , darwin ? null - }: - stdenv.mkDerivation rec { - inherit version; + generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 }: let + versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; + version = "${versionNoPatch}-p${patchLevel}"; + fullVersionName = if patchLevel != "0" && stdenv.lib.versionOlder versionNoPatch "2.1" + then version + else versionNoPatch; + tag = "v" + stdenv.lib.replaceChars ["." "p" "-"] ["_" "_" ""] fullVersionName; + isRuby21 = majorVersion == "2" && minorVersion == "1"; + isRuby18 = majorVersion == "1" && minorVersion == "8"; + baseruby = self.override { useRailsExpress = false; }; + self = lib.makeOverridable ( + { stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub + , useRailsExpress ? true + , zlib, zlibSupport ? true + , openssl, opensslSupport ? true + , gdbm, gdbmSupport ? true + , ncurses, readline, cursesSupport ? true + , groff, docSupport ? false + , libyaml, yamlSupport ? true + , libffi, fiddleSupport ? true + , autoreconfHook, bison, autoconf + , darwin ? null + }: + stdenv.mkDerivation rec { + inherit version; - name = "ruby-${version}"; + name = "ruby-${version}"; - src = if useRailsExpress then fetchFromGitHub { - owner = "ruby"; - repo = "ruby"; - rev = tag; - sha256 = sha256.git; - } else fetchurl { - url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${fullVersionName}.tar.gz"; - sha256 = sha256.src; - }; + src = if useRailsExpress then fetchFromGitHub { + owner = "ruby"; + repo = "ruby"; + rev = tag; + sha256 = sha256.git; + } else fetchurl { + url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${fullVersionName}.tar.gz"; + sha256 = sha256.src; + }; - # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds. - NROFF = "${groff}/bin/nroff"; + # 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 ]) - ++ (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) - ++ (ops stdenv.isDarwin (with darwin; [ libiconv libobjc libunwind ])) - ++ op isRuby18 autoconf; + buildInputs = ops useRailsExpress [ autoreconfHook bison ] + ++ (op fiddleSupport libffi) + ++ (ops cursesSupport [ ncurses readline ]) + ++ (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) + ++ (ops stdenv.isDarwin (with darwin; [ libiconv libobjc libunwind ])) + ++ op isRuby18 autoconf; - enableParallelBuilding = true; + enableParallelBuilding = true; - patches = (import ./patchsets.nix { - inherit patchSet useRailsExpress ops patchLevel; - })."${versionNoPatch}"; + patches = (import ./patchsets.nix { + inherit patchSet useRailsExpress ops patchLevel; + })."${versionNoPatch}"; - postUnpack = opString isRuby21 '' - rm "$sourceRoot/enc/unicode/name2ctype.h" - ''; + postUnpack = opString isRuby21 '' + rm "$sourceRoot/enc/unicode/name2ctype.h" + ''; - postPatch = opString (!isRuby18) (if isRuby21 then '' - rm tool/config_files.rb - cp ${config}/config.guess tool/ - cp ${config}/config.sub tool/ - '' else opString useRailsExpress '' - sed -i configure.in -e '/config.guess/d' - cp ${config}/config.guess tool/ - cp ${config}/config.sub tool/ - ''); + postPatch = opString (!isRuby18) (if isRuby21 then '' + rm tool/config_files.rb + cp ${config}/config.guess tool/ + cp ${config}/config.sub tool/ + '' else opString useRailsExpress '' + sed -i configure.in -e '/config.guess/d' + cp ${config}/config.guess tool/ + cp ${config}/config.sub tool/ + ''); - configureFlags = ["--enable-shared" "--enable-pthread"] - ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" - ++ ops stdenv.isDarwin [ - # on darwin, we have /usr/include/tk.h -- so the configure script detects - # that tk is installed - "--with-out-ext=tk" - # on yosemite, "generating encdb.h" will hang for a very long time without this flag - "--with-setjmp-type=setjmp" - ]; + configureFlags = ["--enable-shared" "--enable-pthread"] + ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" + ++ ops stdenv.isDarwin [ + # on darwin, we have /usr/include/tk.h -- so the configure script detects + # that tk is installed + "--with-out-ext=tk" + # on yosemite, "generating encdb.h" will hang for a very long time without this flag + "--with-setjmp-type=setjmp" + ]; - installFlags = stdenv.lib.optionalString docSupport "install-doc"; - # Bundler tries to create this directory - postInstall = '' + installFlags = stdenv.lib.optionalString docSupport "install-doc"; # Bundler tries to create this directory - mkdir -pv $out/${passthru.gemPath} - mkdir -p $out/nix-support - cat > $out/nix-support/setup-hook < $out/nix-support/setup-hook <