ruby: use stdenv derivation for patching RubyGems

Rather than rolling our own. This means that we can use all of the
extra functionality stdenv gives us, like being able to provide a list
of patches rather than just one.
This commit is contained in:
Alyssa Ross 2019-04-28 12:30:52 +00:00
parent 753e1e0bab
commit bb4fef1499
No known key found for this signature in database
GPG Key ID: F9DBED4859B271C0
3 changed files with 38 additions and 32 deletions

@ -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.nix { 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

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

@ -0,0 +1,31 @@
{ stdenv, lib, fetchurl, fetchpatch }:
stdenv.mkDerivation rec {
name = "rubygems";
version = "2.7.7";
src = fetchurl {
url = "https://rubygems.org/rubygems/rubygems-${version}.tgz";
sha256 = "1jsmmd31j8j066b83lin4bbqz19jhrirarzb41f3sjhfdjiwkcjc";
};
patches = [
(fetchpatch {
url = "https://github.com/zimbatm/rubygems/compare/v2.6.6...v2.6.6-nix.patch";
sha256 = "0297rdb1m6v75q8665ry9id1s74p9305dv32l95ssf198liaihhd";
})
];
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 ];
};
}