diff options
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/ruby')
4 files changed, 134 insertions, 68 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/ruby/default.nix b/nixpkgs/pkgs/development/interpreters/ruby/default.nix index 4011ff61be70..a562411cbb39 100644 --- a/nixpkgs/pkgs/development/interpreters/ruby/default.nix +++ b/nixpkgs/pkgs/development/interpreters/ruby/default.nix @@ -62,14 +62,9 @@ let pname = "ruby"; inherit version; - src = if useRailsExpress then fetchFromGitHub { - owner = "ruby"; - repo = "ruby"; - rev = tag; - sha256 = sha256.git; - } else fetchurl { + src = fetchurl { url = "https://cache.ruby-lang.org/pub/ruby/${ver.majMin}/ruby-${ver}.tar.gz"; - sha256 = sha256.src; + inherit sha256; }; # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds. @@ -87,13 +82,13 @@ let ++ (op opensslSupport openssl) ++ (op gdbmSupport gdbm) ++ (op yamlSupport libyaml) - ++ (op jemallocSupport jemalloc) # 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 [ libiconv libobjc libunwind Foundation ]; + propagatedBuildInputs = op jemallocSupport jemalloc; enableParallelBuilding = true; @@ -104,18 +99,23 @@ let inherit patchSet useRailsExpress ops fetchpatch; patchLevel = ver.patchLevel; }).${ver.majMinTiny} - ++ op (lib.versionOlder ver.majMin "3.1") ./do-not-regenerate-revision.h.patch - ++ op (atLeast30 && useRailsExpress) ./do-not-update-gems-baseruby.patch - # Ruby prior to 3.0 has a bug the installer (tools/rbinstall.rb) but - # the resulting error was swallowed. Newer rubygems no longer swallows - # this error. We upgrade rubygems when rubygemsSupport is enabled, so - # we have to fix this bug to prevent the install step from failing. - # See https://github.com/ruby/ruby/pull/2930 - ++ op (!atLeast30 && rubygemsSupport) + ++ op (atLeast27 && lib.versionOlder ver.majMin "3.1") ./do-not-regenerate-revision.h.patch + ++ op (atLeast30 && useBaseRuby) ./do-not-update-gems-baseruby.patch + ++ ops (!atLeast30 && rubygemsSupport) [ + # We upgrade rubygems to a version that isn't compatible with the + # ruby 2.7 installer. Backport the upstream fix. + ./rbinstall-new-rubygems-compat.patch + + # Ruby prior to 3.0 has a bug the installer (tools/rbinstall.rb) but + # the resulting error was swallowed. Newer rubygems no longer swallows + # this error. We upgrade rubygems when rubygemsSupport is enabled, so + # we have to fix this bug to prevent the install step from failing. + # See https://github.com/ruby/ruby/pull/2930 (fetchpatch { url = "https://github.com/ruby/ruby/commit/261d8dd20afd26feb05f00a560abd99227269c1c.patch"; sha256 = "0wrii25cxcz2v8bgkrf7ibcanjlxwclzhayin578bf0qydxdm9qy"; - }); + }) + ]; postUnpack = opString rubygemsSupport '' rm -rf $sourceRoot/{lib,test}/rubygems* @@ -149,6 +149,10 @@ let (lib.enableFeature docSupport "install-doc") (lib.withFeature jemallocSupport "jemalloc") (lib.withFeatureAs docSupport "ridir" "${placeholder "devdoc"}/share/ri") + # ruby enables -O3 for gcc, however our compiler hardening wrapper + # overrides that by enabling `-O2` which is the minimum optimization + # needed for `_FORTIFY_SOURCE`. + ] ++ lib.optional stdenv.cc.isGNU "CFLAGS=-O3" ++ [ ] ++ ops stdenv.isDarwin [ # on darwin, we have /usr/include/tk.h -- so the configure script detects # that tk is installed @@ -194,6 +198,11 @@ let sed -i '/CC_VERSION_MESSAGE/d' $rbConfig '' } + # Remove unnecessary external intermediate files created by gems + extMakefiles=$(find $out/lib/ruby/gems -name Makefile) + for makefile in $extMakefiles; do + make -C "$(dirname "$makefile")" distclean + done # Bundler tries to create this directory mkdir -p $out/nix-support cat > $out/nix-support/setup-hook <<EOF @@ -263,91 +272,61 @@ let ) args; in self; in { + mkRubyVersion = rubyVersion; + mkRuby = generic; + ruby_1_9 = generic { version = rubyVersion "1" "9" "3" "p551"; - sha256 = { - src = "1s2ibg3s2iflzdv7rfxi1qqkvdbn2dq8gxdn0nxrb77ls5ffanxv"; - git = "1r9xzzxmci2ajb34qb4y1w424mz878zdgzxkfp9w60agldxnb36s"; - }; + sha256 = "1s2ibg3s2iflzdv7rfxi1qqkvdbn2dq8gxdn0nxrb77ls5ffanxv"; }; ruby_2_0 = generic { version = rubyVersion "2" "0" "0" "p648"; - sha256 = { - src = "1y3n4c6xw2wki7pyjpq5zpbgxnw5i3jc8mcpj6rk7hs995mvv446"; - git = "0ncjfq4hfqj9kcr8pbll6kypwnmcgs8w7l4466qqfyv7jj3yjd76"; - }; + sha256 = "1y3n4c6xw2wki7pyjpq5zpbgxnw5i3jc8mcpj6rk7hs995mvv446"; }; ruby_2_1 = generic { version = rubyVersion "2" "1" "10" ""; - sha256 = { - src = "086x66w51lg41abjn79xb7f6xsryymkcc3nvakmkjnjyg96labpv"; - git = "133phd5r5y0np5lc9nqif93l7yb13yd52aspyl6c46z5jhvhyvfi"; - }; + sha256 = "086x66w51lg41abjn79xb7f6xsryymkcc3nvakmkjnjyg96labpv"; }; ruby_2_2 = generic { version = rubyVersion "2" "2" "9" ""; - sha256 = { - src = "19m1ximl7vcrsvq595dgrjh4yb6kar944095wbywqh7waiqcfirg"; - git = "03qrjh55098wcqh2khxryzkzfqkznjrcdgwf27r2bgcycbg5ca5q"; - }; + sha256 = "19m1ximl7vcrsvq595dgrjh4yb6kar944095wbywqh7waiqcfirg"; }; ruby_2_3 = generic { version = rubyVersion "2" "3" "8" ""; - sha256 = { - src = "1gwsqmrhpx1wanrfvrsj3j76rv888zh7jag2si2r14qf8ihns0dm"; - git = "0158fg1sx6l6applbq0831kl8kzx5jacfl9lfg0shfzicmjlys3f"; - }; + sha256 = "1gwsqmrhpx1wanrfvrsj3j76rv888zh7jag2si2r14qf8ihns0dm"; }; ruby_2_4 = generic { version = rubyVersion "2" "4" "9" ""; - sha256 = { - src = "1bn6n5b920qy3lsx99jr8495jkc3sg89swgb96d5fgd579g6p6zr"; - git = "066kb1iki7mx7qkm10xhj5b6v8s47wg68v43l3nc36y2hyim1w2c"; - }; + sha256 = "1bn6n5b920qy3lsx99jr8495jkc3sg89swgb96d5fgd579g6p6zr"; }; ruby_2_5 = generic { version = rubyVersion "2" "5" "8" ""; - sha256 = { - src = "16md4jspjwixjlbhx3pnd5iwpca07p23ghkxkqd82sbchw3xy2vc"; - git = "19gkk3q9l33cwkfsp5k8f8fipq7gkyqkqirm9farbvy425519rv2"; - }; + sha256 = "16md4jspjwixjlbhx3pnd5iwpca07p23ghkxkqd82sbchw3xy2vc"; }; ruby_2_6 = generic { version = rubyVersion "2" "6" "8" ""; - sha256 = { - src = "0vfam28ifl6h2wxi6p70j0hm3f1pvsp432hf75m5j25wfy2vf1qq"; - git = "0rc3n6sk8632r0libpv8jwslc7852hgk64rvbdrspc9razjwx21c"; - }; + sha256 = "0vfam28ifl6h2wxi6p70j0hm3f1pvsp432hf75m5j25wfy2vf1qq"; }; ruby_2_7 = generic { - version = rubyVersion "2" "7" "5" ""; - sha256 = { - src = "1wc1hwmz4m6iqlmqag8liyld917p6a8dvnhnpd1v8d8jl80bjm97"; - git = "16565fyl7141hr6q6d74myhsz46lvgam8ifnacshi68vzibwjbbh"; - }; + version = rubyVersion "2" "7" "6" ""; + sha256 = "042xrdk7hsv4072bayz3f8ffqh61i8zlhvck10nfshllq063n877"; }; ruby_3_0 = generic { - version = rubyVersion "3" "0" "3" ""; - sha256 = { - src = "1b4j39zyyvdkf1ax2c6qfa40b4mxfkr87zghhw19fmnzn8f8d1im"; - git = "1q19w5i1jkfxn7qq6f9v9ngax9h52gxwijk7hp312dx6amwrkaim"; - }; + version = rubyVersion "3" "0" "4" ""; + sha256 = "0avj4g3s2839b2y4m6pk8kid74r8nj7k0qm2rsdcwjzhg8h7rd3h"; }; ruby_3_1 = generic { - version = rubyVersion "3" "1" "1" ""; - sha256 = { - src = "sha256-/m5Hgt6XRDl43bqLpL440iKqJNw+PwKmqOdwHA7rYZ0="; - git = "sha256-76t/tGyK5nz7nvcRdHJTjjckU+Kv+/kbTMiNWJ93jU8="; - }; + version = rubyVersion "3" "1" "2" ""; + sha256 = "0gm84ipk6mrfw94852w5h7xxk2lqrxjbnlwb88svf0lz70933131"; }; } diff --git a/nixpkgs/pkgs/development/interpreters/ruby/patchsets.nix b/nixpkgs/pkgs/development/interpreters/ruby/patchsets.nix index 2114faf74257..79e3c1ad1479 100644 --- a/nixpkgs/pkgs/development/interpreters/ruby/patchsets.nix +++ b/nixpkgs/pkgs/development/interpreters/ruby/patchsets.nix @@ -76,15 +76,15 @@ "${patchSet}/patches/ruby/2.6/head/railsexpress/02-improve-gc-stats.patch" "${patchSet}/patches/ruby/2.6/head/railsexpress/03-more-detailed-stacktrace.patch" ]; - "2.7.5" = ops useRailsExpress [ + "2.7.6" = ops useRailsExpress [ "${patchSet}/patches/ruby/2.7/head/railsexpress/01-fix-broken-tests-caused-by-ad.patch" "${patchSet}/patches/ruby/2.7/head/railsexpress/02-improve-gc-stats.patch" "${patchSet}/patches/ruby/2.7/head/railsexpress/03-more-detailed-stacktrace.patch" ]; - "3.0.3" = ops useRailsExpress [ + "3.0.4" = ops useRailsExpress [ "${patchSet}/patches/ruby/3.0/head/railsexpress/01-improve-gc-stats.patch" "${patchSet}/patches/ruby/3.0/head/railsexpress/02-malloc-trim.patch" ]; - "3.1.1" = ops useRailsExpress [ # no patches yet (2021-12-25) + "3.1.2" = ops useRailsExpress [ # no patches yet (2021-12-25) ]; } diff --git a/nixpkgs/pkgs/development/interpreters/ruby/rbinstall-new-rubygems-compat.patch b/nixpkgs/pkgs/development/interpreters/ruby/rbinstall-new-rubygems-compat.patch new file mode 100644 index 000000000000..54ce8a357a86 --- /dev/null +++ b/nixpkgs/pkgs/development/interpreters/ruby/rbinstall-new-rubygems-compat.patch @@ -0,0 +1,87 @@ +From 8e85d27f9ccfe152fc1b891c19f125915a907493 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> +Date: Tue, 1 Oct 2019 12:03:33 +0200 +Subject: [PATCH] Use `Gem::Package` like object instead of monkey patching. + +1. This is similar to what RubyGems does and it is less magic [[1]]. +2. It avoids deprecated code paths in RubyGems [[2]]. + +[1]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L151 +[2]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L187 + +(cherry picked from commit e960ef6f18a25c637c54f00c75bb6c24f8ab55d0) +--- + tool/rbinstall.rb | 47 +++++++++++++++++++++++++++-------------------- + 1 file changed, 27 insertions(+), 20 deletions(-) + +diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb +index 060390626f..28ae8c409a 100755 +--- a/tool/rbinstall.rb ++++ b/tool/rbinstall.rb +@@ -710,28 +710,34 @@ def remove_prefix(prefix, string) + end + end + +- class UnpackedInstaller < Gem::Installer +- module DirPackage +- def extract_files(destination_dir, pattern = "*") +- path = File.dirname(@gem.path) +- return if path == destination_dir +- File.chmod(0700, destination_dir) +- mode = pattern == "bin/*" ? $script_mode : $data_mode +- spec.files.each do |f| +- src = File.join(path, f) +- dest = File.join(without_destdir(destination_dir), f) +- makedirs(dest[/.*(?=\/)/m]) +- install src, dest, :mode => mode +- end +- File.chmod($dir_mode, destination_dir) ++ class DirPackage ++ attr_reader :spec ++ ++ attr_accessor :dir_mode ++ attr_accessor :prog_mode ++ attr_accessor :data_mode ++ ++ def initialize(spec) ++ @spec = spec ++ @src_dir = File.dirname(@spec.loaded_from) ++ end ++ ++ def extract_files(destination_dir, pattern = "*") ++ path = @src_dir ++ return if path == destination_dir ++ File.chmod(0700, destination_dir) ++ mode = pattern == "bin/*" ? $script_mode : $data_mode ++ spec.files.each do |f| ++ src = File.join(path, f) ++ dest = File.join(without_destdir(destination_dir), f) ++ makedirs(dest[/.*(?=\/)/m]) ++ install src, dest, :mode => mode + end ++ File.chmod($dir_mode, destination_dir) + end ++ end + +- def initialize(spec, *options) +- super(spec.loaded_from, *options) +- @package.extend(DirPackage).spec = spec +- end +- ++ class UnpackedInstaller < Gem::Installer + def write_cache_file + end + +@@ -890,7 +896,8 @@ def install_default_gem(dir, srcdir) + if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}") + spec.extensions[0] ||= "-" + end +- ins = RbInstall::UnpackedInstaller.new(spec, options) ++ package = RbInstall::DirPackage.new spec ++ ins = RbInstall::UnpackedInstaller.new(package, options) + puts "#{INDENT}#{spec.name} #{spec.version}" + ins.install + File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec")) +-- +2.35.1 + diff --git a/nixpkgs/pkgs/development/interpreters/ruby/rubygems/default.nix b/nixpkgs/pkgs/development/interpreters/ruby/rubygems/default.nix index 4150f7683d5d..6a8e171ee6e1 100644 --- a/nixpkgs/pkgs/development/interpreters/ruby/rubygems/default.nix +++ b/nixpkgs/pkgs/development/interpreters/ruby/rubygems/default.nix @@ -1,7 +1,7 @@ { stdenv, lib, fetchurl }: stdenv.mkDerivation rec { - name = "rubygems"; + pname = "rubygems"; version = "3.2.26"; src = fetchurl { |