From bb4fef149914f26ccc65b9b39e584959a05bfc76 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 28 Apr 2019 12:30:52 +0000 Subject: [PATCH] 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. --- .../development/interpreters/ruby/default.nix | 31 +++++-------------- .../interpreters/ruby/rubygems-src.nix | 8 ----- .../interpreters/ruby/rubygems.nix | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) delete mode 100644 pkgs/development/interpreters/ruby/rubygems-src.nix create mode 100644 pkgs/development/interpreters/ruby/rubygems.nix diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index ed2bf99d197..36bd8336269 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -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 diff --git a/pkgs/development/interpreters/ruby/rubygems-src.nix b/pkgs/development/interpreters/ruby/rubygems-src.nix deleted file mode 100644 index 4e5793f1113..00000000000 --- a/pkgs/development/interpreters/ruby/rubygems-src.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ fetchurl -, version ? "2.7.7" -, sha256 ? "1jsmmd31j8j066b83lin4bbqz19jhrirarzb41f3sjhfdjiwkcjc" -}: -fetchurl { - url = "https://rubygems.org/rubygems/rubygems-${version}.tgz"; - sha256 = sha256; -} diff --git a/pkgs/development/interpreters/ruby/rubygems.nix b/pkgs/development/interpreters/ruby/rubygems.nix new file mode 100644 index 00000000000..6b9eff718c7 --- /dev/null +++ b/pkgs/development/interpreters/ruby/rubygems.nix @@ -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 ]; + }; +}