From 9b39be3376aa65a5fa21a65c3b776c7ef39b7b5c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 May 2019 00:37:43 +0200 Subject: [PATCH 1/3] ruby: disable docSupport for baseruby Even if building a Ruby with documentation, there's no reason for its baseruby to waste time building its own documentation as well. --- pkgs/development/interpreters/ruby/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 6f333e13c2b..8689927a2b1 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -26,7 +26,10 @@ let ver = version; tag = ver.gitTag; atLeast25 = lib.versionAtLeast ver.majMin "2.5"; - baseruby = self.override { useRailsExpress = false; }; + baseruby = self.override { + useRailsExpress = false; + docSupport = false; + }; self = lib.makeOverridable ( { stdenv, buildPackages, lib , fetchurl, fetchpatch, fetchFromSavannah, fetchFromGitHub From 6ffb5079b285a8db67856cb3ea43bfbb08310eb5 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 May 2019 00:38:52 +0200 Subject: [PATCH 2/3] ruby: install ri docs to devdoc output This allows getting access to Ruby documentation through ri by doing nix-shell -p ruby ruby.devdoc or by installing the ruby.devdoc package. A setup hook will add a shim to LOAD_PATH to point ri to the devdoc output instead of out. --- .../development/interpreters/ruby/default.nix | 24 ++++++++++++++++-- .../development/interpreters/ruby/rbconfig.rb | 25 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/interpreters/ruby/rbconfig.rb diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 8689927a2b1..cbc505ad802 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -61,6 +61,8 @@ let # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds. NROFF = if docSupport then "${groff}/bin/nroff" else null; + outputs = [ "out" ] ++ lib.optional docSupport "devdoc"; + nativeBuildInputs = [ autoreconfHook bison ] ++ (op docSupport groff) ++ op (stdenv.buildPlatform != stdenv.hostPlatform) buildPackages.ruby; @@ -115,6 +117,10 @@ let ++ op (stdenv.hostPlatform != stdenv.buildPlatform) "--with-baseruby=${buildRuby}"; + preConfigure = opString docSupport '' + configureFlagsArray+=("--with-ridir=$devdoc/share/ri") + ''; + # fails with "16993 tests, 2229489 assertions, 105 failures, 14 errors, 89 skips" # mostly TZ- and patch-related tests # TZ- failures are caused by nix sandboxing, I didn't investigate others @@ -144,12 +150,26 @@ let addGemPath() { addToSearchPath GEM_PATH \$1/${passthru.gemPath} } + addRubyLibPath() { + addToSearchPath RUBYLIB \$1/lib/ruby/site_ruby + addToSearchPath RUBYLIB \$1/lib/ruby/site_ruby/${ver.libDir} + addToSearchPath RUBYLIB \$1/lib/ruby/site_ruby/${ver.libDir}/${stdenv.targetPlatform.system} + } addEnvHooks "$hostOffset" addGemPath + addEnvHooks "$hostOffset" addRubyLibPath EOF - '' + opString useRailsExpress '' - rbConfig=$(find $out/lib/ruby -name rbconfig.rb) + rbConfig=$(find $out/lib/ruby -name rbconfig.rb) + '' + opString docSupport '' + # Prevent the docs from being included in the closure + sed -i "s|\$(DESTDIR)$devdoc|\$(datarootdir)/\$(RI_BASE_NAME)|" $rbConfig + sed -i "s|'--with-ridir=$devdoc/share/ri'||" $rbConfig + + # Add rbconfig shim so ri can find docs + mkdir -p $devdoc/lib/ruby/site_ruby + cp ${./rbconfig.rb} $devdoc/lib/ruby/site_ruby/rbconfig.rb + '' + opString useRailsExpress '' # Prevent the baseruby from being included in the closure. sed -i '/^ CONFIG\["BASERUBY"\]/d' $rbConfig sed -i "s|'--with-baseruby=${baseruby}/bin/ruby'||" $rbConfig diff --git a/pkgs/development/interpreters/ruby/rbconfig.rb b/pkgs/development/interpreters/ruby/rbconfig.rb new file mode 100644 index 00000000000..eeba930b54b --- /dev/null +++ b/pkgs/development/interpreters/ruby/rbconfig.rb @@ -0,0 +1,25 @@ +# This is a shim around whatever real rbconfig.rb is in the LOAD_PATH, +# so that RbConfig::CONFIG["ridir"] can be overridden to point to the +# custom location of the ri docs, without the main derivation having +# those docs in its closure. + +MY_PATH = File.realpath(__FILE__) + +candidates = $LOAD_PATH.map { |dir| File.join(dir, "rbconfig.rb") } + +# First, drop everything _before_ this file in the LOAD_PATH, just on +# the off-chance somebody is composing shims like this for some reason. +candidates.drop_while { |c| !File.exist?(c) || File.realpath(c) != MY_PATH } + +# Now, the wrapped rbconfig.rb is the next rbconfig.rb in the LOAD_PATH +# that isn't this same file. (Yes, duplicate LOAD_PATH entries are a +# thing we have to deal with.) +next_rbconfig = candidates.find { |c| + File.exist?(c) && File.realpath(c) != MY_PATH +} + +# Load the wrapped rbconfig.rb +require next_rbconfig + +# Now we have RbConfig, and can modify it for our own ends. +RbConfig::CONFIG["ridir"] = File.expand_path("../../../share/ri", __dir__) From b34608d4ea3f41efc8b68964e1b14650d4c164bd Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 May 2019 00:39:16 +0200 Subject: [PATCH 3/3] ruby: enable docSupport by default Now that RI docs are installed to a seperate output, we don't need to worry about bloating the main output, so it's reasonable for this to be enabled by default. --- pkgs/development/interpreters/ruby/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index cbc505ad802..e6c8a123041 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -38,7 +38,7 @@ let , openssl, opensslSupport ? true , gdbm, gdbmSupport ? true , ncurses, readline, cursesSupport ? true - , groff, docSupport ? false + , groff, docSupport ? true , libyaml, yamlSupport ? true , libffi, fiddleSupport ? true , autoreconfHook, bison, autoconf