diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 3b051eac87b..96d73d45c26 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -21,6 +21,7 @@ let generic = { version, sha256, cargoSha256 ? null }: let ver = version; atLeast30 = lib.versionAtLeast ver.majMin "3.0"; + atLeast31 = lib.versionAtLeast ver.majMin "3.1"; atLeast32 = lib.versionAtLeast ver.majMin "3.2"; self = lib.makeOverridable ( { stdenv, buildPackages, lib @@ -96,7 +97,10 @@ let enableParallelBuilding = true; patches = op (lib.versionOlder ver.majMin "3.1") ./do-not-regenerate-revision.h.patch - ++ op (atLeast30 && useBaseRuby) ./do-not-update-gems-baseruby.patch + ++ op (atLeast30 && useBaseRuby) ( + if atLeast32 then ./do-not-update-gems-baseruby-3.2.patch + else ./do-not-update-gems-baseruby.patch + ) ++ ops (ver.majMin == "3.0") [ # Ruby 3.0 adds `-fdeclspec` to $CC instead of $CFLAGS. Fixed in later versions. (fetchpatch { @@ -104,6 +108,14 @@ let sha256 = "sha256-43hI9L6bXfeujgmgKFVmiWhg7OXvshPCCtQ4TxqK1zk="; }) ] + ++ ops (ver.majMin == "3.1") [ + # Ruby 3.1.3 cannot find pkg-config in mkmf.rb + # https://bugs.ruby-lang.org/issues/19189 + (fetchpatch { + url = "https://github.com/ruby/ruby/commit/613fca01486e47dee9364a2fd86b5f5e77fe23c8.patch"; + sha256 = "sha256-0Ku7l6VEpcvxexL9QA5+mNER4v8gYZOJhAjhCL1WDpw="; + }) + ] ++ ops (!atLeast30 && rubygemsSupport) [ # We upgrade rubygems to a version that isn't compatible with the # ruby 2.7 installer. Backport the upstream fix. @@ -118,6 +130,13 @@ let url = "https://github.com/ruby/ruby/commit/261d8dd20afd26feb05f00a560abd99227269c1c.patch"; sha256 = "0wrii25cxcz2v8bgkrf7ibcanjlxwclzhayin578bf0qydxdm9qy"; }) + ] + ++ ops atLeast31 [ + # When using a baseruby, ruby always sets "libdir" to the build + # directory, which nix rejects due to a reference in to /build/ in + # the final product. Removing this reference doesn't seem to break + # anything and fixes cross compliation. + ./dont-refer-to-build-dir.patch ]; cargoRoot = opString yjitSupport "yjit"; diff --git a/pkgs/development/interpreters/ruby/do-not-update-gems-baseruby-3.2.patch b/pkgs/development/interpreters/ruby/do-not-update-gems-baseruby-3.2.patch new file mode 100644 index 00000000000..21e8d0fffe6 --- /dev/null +++ b/pkgs/development/interpreters/ruby/do-not-update-gems-baseruby-3.2.patch @@ -0,0 +1,13 @@ +diff --git a/common.mk b/common.mk +index 3798f82bc6..4d07b28aa4 100644 +--- a/common.mk ++++ b/common.mk +@@ -1374,7 +1374,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: + extract-gems: $(HAVE_BASERUBY:yes=update-gems) + + update-gems$(gnumake:yes=-sequential): PHONY diff --git a/pkgs/development/interpreters/ruby/dont-refer-to-build-dir.patch b/pkgs/development/interpreters/ruby/dont-refer-to-build-dir.patch new file mode 100644 index 00000000000..6198b3acc9e --- /dev/null +++ b/pkgs/development/interpreters/ruby/dont-refer-to-build-dir.patch @@ -0,0 +1,12 @@ +diff --git a/tool/fake.rb b/tool/fake.rb +index 91dfb041c4..9c235f1e3a 100644 +--- a/tool/fake.rb ++++ b/tool/fake.rb +@@ -48,7 +48,6 @@ class File + $builtruby ||= File.join(builddir, config['RUBY_INSTALL_NAME'] + config['EXEEXT']) + RbConfig.fire_update!("builddir", builddir) + RbConfig.fire_update!("buildlibdir", builddir) +- RbConfig.fire_update!("libdir", builddir) + RbConfig.fire_update!("prefix", $topdir) + RbConfig.fire_update!("top_srcdir", $top_srcdir ||= top_srcdir) + RbConfig.fire_update!("extout", $extout)