From 3cf05b37f2215eb225a9b36b565ef30516845b79 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Tue, 29 Dec 2020 04:20:00 +0000 Subject: [PATCH 1/4] ruby: update RVM patchsets --- pkgs/development/interpreters/ruby/rvm-patchsets.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/interpreters/ruby/rvm-patchsets.nix b/pkgs/development/interpreters/ruby/rvm-patchsets.nix index 14f932e1d65c..3c2113d608c5 100644 --- a/pkgs/development/interpreters/ruby/rvm-patchsets.nix +++ b/pkgs/development/interpreters/ruby/rvm-patchsets.nix @@ -3,6 +3,6 @@ fetchFromGitHub { owner = "skaes"; repo = "rvm-patchsets"; - rev = "e2f4b82e47aeaf2a3b894da3b46ba6f0ca92cbb6"; - sha256 = "059mvf8jcjrfplr8hv2y6ibc41id979k0zwfh6zdnb7dynym4bsg"; + rev = "28c6469ce841ff3033c376e78a7043009a3bdc5c"; + sha256 = "0kh08hahrwif61sq0qlvgyqiymxi8c8h2dw4s3ln4aq696k4gba9"; } From 1b3130ec1aee306a34441773e4bf744183dbae95 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Tue, 29 Dec 2020 04:20:00 +0000 Subject: [PATCH 2/4] ruby_3_0: init 3.0.0 https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ --- .../development/interpreters/ruby/default.nix | 24 +++++++++++++------ .../ruby/do-not-regenerate-revision.h.patch | 23 ++++++++++++++++++ .../ruby/do-not-update-gems-baseruby.patch | 14 +++++++++++ .../interpreters/ruby/patchsets.nix | 4 ++++ pkgs/top-level/all-packages.nix | 4 +++- 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/interpreters/ruby/do-not-regenerate-revision.h.patch create mode 100644 pkgs/development/interpreters/ruby/do-not-update-gems-baseruby.patch diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 65189fda0793..d53edaad03e1 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -27,6 +27,7 @@ let ver = version; tag = ver.gitTag; atLeast27 = lib.versionAtLeast ver.majMin "2.7"; + atLeast30 = lib.versionAtLeast ver.majMin "3.0"; baseruby = self.override { useRailsExpress = false; docSupport = false; @@ -109,7 +110,9 @@ let (import ./patchsets.nix { inherit patchSet useRailsExpress ops fetchpatch; patchLevel = ver.patchLevel; - }).${ver.majMinTiny}; + }).${ver.majMinTiny} + ++ op atLeast27 ./do-not-regenerate-revision.h.patch + ++ op (atLeast30 && useRailsExpress) ./do-not-update-gems-baseruby.patch; postUnpack = opString rubygemsSupport '' rm -rf $sourceRoot/{lib,test}/rubygems* @@ -121,17 +124,12 @@ let sed -i configure.ac -e '/config.guess/d' cp --remove-destination ${config}/config.guess tool/ cp --remove-destination ${config}/config.sub tool/ + '' + opString (!atLeast30) '' # Make the build reproducible for ruby <= 2.7 # See https://github.com/ruby/io-console/commit/679a941d05d869f5e575730f6581c027203b7b26#diff-d8422f096931c58d4463e2489f62a228b0f24f0492950ba88c8c89a0d741cfe6 sed -i ext/io/console/io-console.gemspec -e '/s\.date/d' ''; - # Force the revision.h generation. Somehow `revision.tmp` is an empty - # file and because we don't add `git` to buildInputs, hence the check is - # always true. - # https://github.com/ruby/ruby/commit/97a5af62a318fcd93a4e5e4428d576c0280ddbae - buildFlags = lib.optionals atLeast27 [ "REVISION_LATEST=0" ]; - configureFlags = ["--enable-shared" "--enable-pthread" "--with-soname=ruby-${version}"] ++ op useRailsExpress "--with-baseruby=${baseruby}/bin/ruby" ++ op (!jitSupport) "--disable-jit-support" @@ -149,6 +147,10 @@ let preConfigure = opString docSupport '' configureFlagsArray+=("--with-ridir=$devdoc/share/ri") + + # rdoc creates XDG_DATA_DIR (defaulting to $HOME/.local/share) even if + # it's not going to be used. + export HOME=$TMPDIR ''; # fails with "16993 tests, 2229489 assertions, 105 failures, 14 errors, 89 skips" @@ -261,4 +263,12 @@ in { git = "0kbgznf1yprfp9645k31ra5f4757b7fichzi0hdg6nxkj90853s0"; }; }; + + ruby_3_0 = generic { + version = rubyVersion "3" "0" "0" ""; + sha256 = { + src = "0a4fmxafxvkg1m738g2lmkhipwnmd96kzqy1m9kvk3n1l50x2gm1"; + git = "0fvnxv97m94nridlc5nvvrlg53pr5g042dkfc5ysd327s7xj4cjp"; + }; + }; } diff --git a/pkgs/development/interpreters/ruby/do-not-regenerate-revision.h.patch b/pkgs/development/interpreters/ruby/do-not-regenerate-revision.h.patch new file mode 100644 index 000000000000..ddeb368ee8ae --- /dev/null +++ b/pkgs/development/interpreters/ruby/do-not-regenerate-revision.h.patch @@ -0,0 +1,23 @@ +Do not regenerate revision.h + +Ruby's makefile compares the shipped version with the git revision to regenerate +revision.h [1], but since we don't include git in buildInputs, this comparison +fails and it can't find $(REVISION_H). + +[1] https://github.com/ruby/ruby/commit/97a5af62a318fcd93a4e5e4428d576c0280ddbae + +diff -Naur ruby.old/defs/gmake.mk ruby.new/defs/gmake.mk +--- ruby.old/defs/gmake.mk ++++ ruby.new/defs/gmake.mk +@@ -325,11 +325,9 @@ + + REVISION_IN_HEADER := $(shell sed -n 's/^\#define RUBY_FULL_REVISION "\(.*\)"/\1/p' $(srcdir)/revision.h 2>/dev/null) + REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && git log -1 --format=%H 2>/dev/null) +-ifneq ($(REVISION_IN_HEADER),$(REVISION_LATEST)) + # GNU make treat the target as unmodified when its dependents get + # updated but it is not updated, while others may not. + $(srcdir)/revision.h: $(REVISION_H) +-endif + + # Query on the generated rdoc + # diff --git a/pkgs/development/interpreters/ruby/do-not-update-gems-baseruby.patch b/pkgs/development/interpreters/ruby/do-not-update-gems-baseruby.patch new file mode 100644 index 000000000000..2de1977630cb --- /dev/null +++ b/pkgs/development/interpreters/ruby/do-not-update-gems-baseruby.patch @@ -0,0 +1,14 @@ +Do not update gems when building with base ruby + +diff -Naur ruby.old/defs/gmake.mk ruby.new/defs/gmake.mk +--- ruby.old/common.mk ++++ ruby.new/common.mk +@@ -1298,7 +1298,7 @@ update-config_files: PHONY + config.guess config.sub + + refresh-gems: update-bundled_gems prepare-gems +-prepare-gems: $(HAVE_BASERUBY:yes=update-gems) $(HAVE_BASERUBY:yes=extract-gems) ++prepare-gems: + + update-gems$(gnumake:yes=-nongnumake): PHONY + $(ECHO) Downloading bundled gem files... diff --git a/pkgs/development/interpreters/ruby/patchsets.nix b/pkgs/development/interpreters/ruby/patchsets.nix index 69f224641849..246d44e20d16 100644 --- a/pkgs/development/interpreters/ruby/patchsets.nix +++ b/pkgs/development/interpreters/ruby/patchsets.nix @@ -16,4 +16,8 @@ "${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.0" = 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" + ]; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fba1a0f30f78..2818e46010da 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11561,13 +11561,15 @@ in bison = buildPackages.bison_3_5; }) ruby_2_6 - ruby_2_7; + ruby_2_7 + ruby_3_0; ruby = ruby_2_6; rubyPackages = rubyPackages_2_6; rubyPackages_2_6 = recurseIntoAttrs ruby_2_6.gems; rubyPackages_2_7 = recurseIntoAttrs ruby_2_7.gems; + rubyPackages_3_0 = recurseIntoAttrs ruby_3_0.gems; mruby = callPackage ../development/compilers/mruby { }; From 9db5a83465a173fef7204302ac08533b411d6359 Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Mon, 22 Feb 2021 04:20:00 +0000 Subject: [PATCH 3/4] ruby_2_5: remove patchset ruby_2_5 was removed from nixpkgs in 1c33c0ad6b1b9a335c9a2c6747849309fb817eca --- pkgs/development/interpreters/ruby/patchsets.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkgs/development/interpreters/ruby/patchsets.nix b/pkgs/development/interpreters/ruby/patchsets.nix index 246d44e20d16..3abba61bc246 100644 --- a/pkgs/development/interpreters/ruby/patchsets.nix +++ b/pkgs/development/interpreters/ruby/patchsets.nix @@ -1,11 +1,6 @@ { patchSet, useRailsExpress, ops, patchLevel, fetchpatch }: { - "2.5.8" = ops useRailsExpress [ - "${patchSet}/patches/ruby/2.5/head/railsexpress/01-fix-broken-tests-caused-by-ad.patch" - "${patchSet}/patches/ruby/2.5/head/railsexpress/02-improve-gc-stats.patch" - "${patchSet}/patches/ruby/2.5/head/railsexpress/03-more-detailed-stacktrace.patch" - ]; "2.6.6" = ops useRailsExpress [ "${patchSet}/patches/ruby/2.6/head/railsexpress/01-fix-broken-tests-caused-by-ad.patch" "${patchSet}/patches/ruby/2.6/head/railsexpress/02-improve-gc-stats.patch" From 7121ef61da4ddd36f81480322bc2ae984c575b1d Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Mon, 22 Feb 2021 04:20:00 +0000 Subject: [PATCH 4/4] buildRubyGem: update CFLAGS for ruby 3.0 on Clang --- pkgs/development/ruby-modules/gem/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index 9e64b120af85..02af8eaa9672 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -129,6 +129,12 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // { runHook postUnpack ''; + # As of ruby 3.0, ruby headers require -fdeclspec when building with clang + # Introduced in https://github.com/ruby/ruby/commit/0958e19ffb047781fe1506760c7cbd8d7fe74e57 + NIX_CFLAGS_COMPILE = lib.optionals (stdenv.cc.isClang && lib.versionAtLeast ruby.version.major "3") [ + "-fdeclspec" + ]; + buildPhase = attrs.buildPhase or '' runHook preBuild