From 5379504451c67b9773191d4cc56638072d3239d3 Mon Sep 17 00:00:00 2001 From: Jude Taylor Date: Sat, 26 Sep 2015 06:25:01 -0700 Subject: [PATCH] Merge pull request #9834 from NixOS/rubies Merge Ruby versions into one file --- .../development/interpreters/ruby/default.nix | 248 ++++++++++++++++++ .../interpreters/ruby/patchsets.nix | 126 +++++++++ .../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 | 24 +- 12 files changed, 381 insertions(+), 1069 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.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 000000000000..89e0016f98de --- /dev/null +++ b/pkgs/development/interpreters/ruby/default.nix @@ -0,0 +1,248 @@ +{ stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub +, zlib, openssl, gdbm, ncurses, readline, groff, libyaml, libffi, autoreconfHook, bison +, autoconf, darwin ? null +} @ args: + +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 }: 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 = 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"; + + 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; + + patches = (import ./patchsets.nix { + inherit patchSet useRailsExpress ops patchLevel; + })."${versionNoPatch}"; + + 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/ + ''); + + 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 = '' + # 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 <= 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 <