From c4b44b477144ffce2f6291f9dd13ffe36831db3d Mon Sep 17 00:00:00 2001 From: Kaidong Hu Date: Wed, 28 Jan 2026 21:50:55 -0500 Subject: [PATCH 1/2] test: add docSupport test and add docSupport version check There is a do-install-doc issue related to ruby version < 3.4. This commit checks doc support for ruby version >= 3.4 and add guard perventing docSupport be used in parallel build with early versions. See: https://github.com/ruby/rubygems/issues/7580 --- flake.nix | 20 +++++++++++++++++++- ruby/package-fn.nix | 7 ++++++- rubygems/package-fn.nix | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 43363cf..811436c 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ versionedPackageFnWithOverrides = { version, versionSource }: let pkg = pkgs.callPackage packageFn { - inherit version versionSource; + inherit version versionSource versionComparison; }; in applyOverrides { @@ -191,6 +191,24 @@ ruby -e 'require "foobar"; say' > $out ''; }; + }) // (lib.optionalAttrs (with versionComparison rubyVersion; greaterOrEqualTo "3.4") { + "${rubyName}-docSupport" = { + nativeBuildInputs = [ + (ruby.override { docSupport = true; }) + ]; + command = '' + ri Array > $out + ''; + }; + }) // (lib.optionalAttrs (with versionComparison rubyVersion; lessThan "3.4") { + "${rubyName}-docSupport-noParallel" = { + nativeBuildInputs = [ + (ruby.override { docSupport = true; parallelBuild = false; }) + ]; + command = '' + ri Array > $out + ''; + }; }) ) rubyPackages; diff --git a/ruby/package-fn.nix b/ruby/package-fn.nix index c91cd46..b83ba4b 100644 --- a/ruby/package-fn.nix +++ b/ruby/package-fn.nix @@ -1,5 +1,6 @@ { version , versionSource +, versionComparison , libDir ? "${(import ./parse-version.nix version).majMin}.0" , rubygems ? null , stdenv @@ -25,6 +26,7 @@ , bundler , bundix , removeReferencesTo +, parallelBuild ? true , useRailsExpress ? true , zlibSupport ? true , opensslSupport ? true @@ -87,7 +89,7 @@ let propagatedBuildInputs = (op jemallocSupport jemalloc); - enableParallelBuilding = true; + enableParallelBuilding = parallelBuild; postPatch = '' ${opString (rubygems != null) '' @@ -195,4 +197,7 @@ let }; }; in +# There's a known race condition when building with docs enabled before Ruby 3.4.0 +# Building documents requires parallelBuild to be false in those versions +assert docSupport -> (with versionComparison version; greaterOrEqualTo "3.4.0" || !parallelBuild); self diff --git a/rubygems/package-fn.nix b/rubygems/package-fn.nix index 97d46c6..a7fea1d 100644 --- a/rubygems/package-fn.nix +++ b/rubygems/package-fn.nix @@ -3,6 +3,7 @@ , stdenv , fetchurl , fetchpatch +, ... }: stdenv.mkDerivation { pname = "rubygems"; From 17a24748a83eaff13a8373e8bed269c79d77f964 Mon Sep 17 00:00:00 2001 From: Kaidong Hu Date: Sat, 11 Apr 2026 14:37:19 -0400 Subject: [PATCH 2/2] Fix docSupport build failure in Nix sandbox rdoc tries to create XDG_DATA_DIR (defaulting to $HOME/.local/share) during the build, but $HOME is read-only in the Nix sandbox. This adds a writable $HOME during the preConfigure phase, and applies the same fix to the docSupport tests in flake.nix. See: https://github.com/bobvanderlinden/nixpkgs-ruby/pull/221 Co-Authored-By: Sander --- flake.nix | 4 ++-- ruby/package-fn.nix | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 811436c..824d143 100644 --- a/flake.nix +++ b/flake.nix @@ -197,7 +197,7 @@ (ruby.override { docSupport = true; }) ]; command = '' - ri Array > $out + HOME=$TMPDIR ri Array > $out ''; }; }) // (lib.optionalAttrs (with versionComparison rubyVersion; lessThan "3.4") { @@ -206,7 +206,7 @@ (ruby.override { docSupport = true; parallelBuild = false; }) ]; command = '' - ri Array > $out + HOME=$TMPDIR ri Array > $out ''; }; }) diff --git a/ruby/package-fn.nix b/ruby/package-fn.nix index b83ba4b..cee84ec 100644 --- a/ruby/package-fn.nix +++ b/ruby/package-fn.nix @@ -109,6 +109,11 @@ let preConfigure = '' sed -i configure -e 's/;; #(/\n;;/g' + ${opString docSupport '' + # rdoc creates XDG_DATA_DIR (defaulting to $HOME/.local/share) even if + # it's not going to be used. + export HOME=$TMPDIR + ''} ''; configureFlags =