Merge pull request #60394 from alyssais/rubygems

ruby: rubygems 2.7.7 -> 3.0.3
This commit is contained in:
Alyssa Ross 2019-05-01 23:23:41 +00:00 committed by GitHub
commit 3567b1390f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 125 additions and 32 deletions

View file

@ -11,14 +11,7 @@ let
opString = lib.optionalString;
patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; };
config = import ./config.nix { inherit fetchFromSavannah; };
rubygemsSrc = import ./rubygems-src.nix { inherit fetchurl; };
rubygemsPatch = fetchpatch {
url = "https://github.com/zimbatm/rubygems/compare/v2.6.6...v2.6.6-nix.patch";
sha256 = "0297rdb1m6v75q8665ry9id1s74p9305dv32l95ssf198liaihhd";
};
unpackdir = obj:
lib.removeSuffix ".tgz"
(lib.removeSuffix ".tar.gz" obj.name);
rubygems = import ./rubygems { inherit stdenv lib fetchurl fetchpatch; };
# Contains the ruby version heuristics
rubyVersion = import ./ruby-version.nix { inherit lib; };
@ -49,8 +42,10 @@ let
, buildEnv, bundler, bundix
, libiconv, libobjc, libunwind, Foundation
}:
let rubySrc =
if useRailsExpress then fetchFromGitHub {
stdenv.mkDerivation rec {
name = "ruby-${version}";
src = if useRailsExpress then fetchFromGitHub {
owner = "ruby";
repo = "ruby";
rev = tag;
@ -59,16 +54,6 @@ let
url = "https://cache.ruby-lang.org/pub/ruby/${ver.majMin}/ruby-${ver}.tar.gz";
sha256 = sha256.src;
};
in
stdenv.mkDerivation rec {
name = "ruby-${version}";
srcs = [ rubySrc rubygemsSrc ];
sourceRoot =
if useRailsExpress then
rubySrc.name
else
unpackdir rubySrc;
# Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
NROFF = if docSupport then "${groff}/bin/nroff" else null;
@ -100,10 +85,7 @@ let
})."${ver.majMinTiny}";
postUnpack = ''
cp -r ${unpackdir rubygemsSrc} ${sourceRoot}/rubygems
pushd ${sourceRoot}/rubygems
patch -p1 < ${rubygemsPatch}
popd
cp -r ${rubygems} $sourceRoot/rubygems
'';
postPatch = if atLeast25 then ''
@ -146,6 +128,7 @@ let
postInstall = ''
# Update rubygems
pushd rubygems
chmod +w bundler/bundler.gemspec
${buildRuby} setup.rb --destdir $GEM_HOME
popd

View file

@ -1,8 +0,0 @@
{ fetchurl
, version ? "2.7.7"
, sha256 ? "1jsmmd31j8j066b83lin4bbqz19jhrirarzb41f3sjhfdjiwkcjc"
}:
fetchurl {
url = "https://rubygems.org/rubygems/rubygems-${version}.tgz";
sha256 = sha256;
}

View file

@ -0,0 +1,34 @@
From a6485cfcdf51ff8be452980f93cebfea97f34dec Mon Sep 17 00:00:00 2001
From: zimbatm <zimbatm@zimbatm.com>
Date: Wed, 21 Sep 2016 09:32:34 +0100
Subject: [PATCH 1/3] add post-extract hook
Allows nix to execute scripts just after the gem extraction
---
lib/rubygems/installer.rb | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index d26b1e88..bf18fb7f 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -848,7 +848,15 @@ TEXT
# Ensures that files can't be installed outside the gem directory.
def extract_files
- @package.extract_files gem_dir
+ ret = @package.extract_files gem_dir
+ if ENV['NIX_POST_EXTRACT_FILES_HOOK']
+ puts
+ puts "running NIX_POST_EXTRACT_FILES_HOOK #{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{gem_dir}"
+ system(ENV['NIX_POST_EXTRACT_FILES_HOOK'], gem_dir.to_s)
+ puts "running NIX_POST_EXTRACT_FILES_HOOK done"
+ puts
+ end
+ ret
end
##
--
2.21.0

View file

@ -0,0 +1,28 @@
From 2e1328bcdddd35e557eabdff83ac07f3591dc693 Mon Sep 17 00:00:00 2001
From: zimbatm <zimbatm@zimbatm.com>
Date: Wed, 21 Sep 2016 19:37:05 +0100
Subject: [PATCH 2/3] binaries with env shebang
By default, don't point to the absolute ruby derivation path. As a user
installing a gem in the home, it would freeze the selected ruby version
to the currently-installed ruby derivation.
---
lib/rubygems/dependency_installer.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 34620860..00ab31d9 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -18,7 +18,7 @@ class Gem::DependencyInstaller
extend Gem::Deprecate
DEFAULT_OPTIONS = { # :nodoc:
- :env_shebang => false,
+ :env_shebang => true,
:document => %w[ri],
:domain => :both, # HACK dup
:force => false,
--
2.21.0

View file

@ -0,0 +1,26 @@
From d69249d0ff210316121b44d971ddd2439b1bc393 Mon Sep 17 00:00:00 2001
From: zimbatm <zimbatm@zimbatm.com>
Date: Wed, 21 Sep 2016 09:40:39 +0100
Subject: [PATCH 3/3] gem install default to user
Default to not installing gems to the read-only system derivation.
---
lib/rubygems/path_support.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb
index ed680d65..749b9ea6 100644
--- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -23,7 +23,7 @@ class Gem::PathSupport
# hashtable, or defaults to ENV, the system environment.
#
def initialize(env)
- @home = env["GEM_HOME"] || Gem.default_dir
+ @home = env["GEM_HOME"] || Gem.user_dir
if File::ALT_SEPARATOR
@home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
--
2.21.0

View file

@ -0,0 +1,30 @@
{ stdenv, lib, fetchurl, fetchpatch }:
stdenv.mkDerivation rec {
name = "rubygems";
version = "3.0.3";
src = fetchurl {
url = "https://rubygems.org/rubygems/rubygems-${version}.tgz";
sha256 = "0b6b9ads8522804xv8b8498gqwsv4qawv13f81kyc7g966y7lfmy";
};
patches = [
./0001-add-post-extract-hook.patch
./0002-binaries-with-env-shebang.patch
./0003-gem-install-default-to-user.patch
];
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
meta = with lib; {
description = "Package management framework for Ruby";
homepage = https://rubygems.org/;
license = with licenses; [ mit /* or */ ruby ];
maintainers = with maintainers; [ qyliss zimbatm ];
};
}