summary refs log tree commit diff
path: root/pkgs/development/interpreters/ruby
diff options
context:
space:
mode:
authorMario Rodas <marsam@users.noreply.github.com>2020-12-29 04:20:00 +0000
committerMario Rodas <marsam@users.noreply.github.com>2020-12-29 04:20:00 +0000
commit1b3130ec1aee306a34441773e4bf744183dbae95 (patch)
tree1293dae526140a6f526da0f57c68ae94f159628e /pkgs/development/interpreters/ruby
parent3cf05b37f2215eb225a9b36b565ef30516845b79 (diff)
downloadnixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.tar
nixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.tar.gz
nixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.tar.bz2
nixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.tar.lz
nixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.tar.xz
nixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.tar.zst
nixpkgs-1b3130ec1aee306a34441773e4bf744183dbae95.zip
ruby_3_0: init 3.0.0
https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
Diffstat (limited to 'pkgs/development/interpreters/ruby')
-rw-r--r--pkgs/development/interpreters/ruby/default.nix24
-rw-r--r--pkgs/development/interpreters/ruby/do-not-regenerate-revision.h.patch23
-rw-r--r--pkgs/development/interpreters/ruby/do-not-update-gems-baseruby.patch14
-rw-r--r--pkgs/development/interpreters/ruby/patchsets.nix4
4 files changed, 58 insertions, 7 deletions
diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix
index 65189fda079..d53edaad03e 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 00000000000..ddeb368ee8a
--- /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 00000000000..2de1977630c
--- /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 69f22464184..246d44e20d1 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"
+  ];
 }