ruby: install rubygems directly into the derivation
Having a separate rubygems package can lead to split-brain scenarios. Since rubygems is designed to replace himself on a ruby installation, let's do that.
This commit is contained in:
parent
13c6b9ba85
commit
86f1579266
@ -18,7 +18,7 @@
|
||||
# Normal gem packages can be used outside of bundler; a binstub is created in
|
||||
# $out/bin.
|
||||
|
||||
{ lib, ruby, rubygems, bundler, fetchurl, fetchgit, makeWrapper, git,
|
||||
{ lib, ruby, bundler, fetchurl, fetchgit, makeWrapper, git,
|
||||
buildRubyGem, darwin
|
||||
} @ defs:
|
||||
|
||||
@ -54,9 +54,6 @@ lib.makeOverridable (
|
||||
|
||||
let
|
||||
shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
|
||||
rubygems = (attrs.rubygems or defs.rubygems).override {
|
||||
inherit ruby;
|
||||
};
|
||||
src = attrs.src or (
|
||||
if type == "gem" then
|
||||
fetchurl {
|
||||
@ -79,14 +76,14 @@ let
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (attrs // {
|
||||
inherit ruby rubygems;
|
||||
inherit ruby;
|
||||
inherit doCheck;
|
||||
inherit dontBuild;
|
||||
inherit dontStrip;
|
||||
inherit type;
|
||||
|
||||
buildInputs = [
|
||||
ruby rubygems makeWrapper
|
||||
ruby makeWrapper
|
||||
] ++ lib.optionals (type == "git") [ git bundler ]
|
||||
++ lib.optional stdenv.isDarwin darwin.libobjc
|
||||
++ buildInputs;
|
||||
|
@ -1,6 +1,5 @@
|
||||
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
|
||||
, callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem, buildEnv
|
||||
, rubygems
|
||||
, git
|
||||
, makeWrapper
|
||||
, bundler
|
||||
@ -28,10 +27,9 @@ let
|
||||
);
|
||||
hasBundler = builtins.hasAttr "bundler" importedGemset;
|
||||
bundler = if hasBundler then gems.bundler else defs.bundler.override (attrs: { inherit ruby; });
|
||||
rubygems = defs.rubygems.override (attrs: { inherit ruby; });
|
||||
gems = lib.flip lib.mapAttrs configuredGemset (name: attrs:
|
||||
buildRubyGem ((removeAttrs attrs ["source"]) // attrs.source // {
|
||||
inherit ruby rubygems;
|
||||
inherit ruby;
|
||||
gemName = name;
|
||||
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
|
||||
}));
|
||||
@ -45,7 +43,6 @@ let
|
||||
|
||||
cd $out
|
||||
chmod +w Gemfile.lock
|
||||
source ${rubygems}/nix-support/setup-hook
|
||||
export GEM_PATH=${bundler}/${ruby.gemPath}
|
||||
${ruby}/bin/ruby -rubygems -e \
|
||||
"require 'bundler'; Bundler.definition.lock('Gemfile.lock')"
|
||||
@ -56,8 +53,6 @@ let
|
||||
paths = envPaths;
|
||||
pathsToLink = [ "/lib" ];
|
||||
postBuild = ''
|
||||
source ${rubygems}/nix-support/setup-hook
|
||||
|
||||
${ruby}/bin/ruby ${./gen-bin-stubs.rb} \
|
||||
"${ruby}/bin/ruby" \
|
||||
"${confFiles}/Gemfile" \
|
||||
|
@ -9,6 +9,10 @@ let
|
||||
opString = stdenv.lib.optionalString;
|
||||
patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; };
|
||||
config = import ./config.nix { inherit fetchFromSavannah; };
|
||||
rubygemsSrc = import ./rubygems-src.nix { inherit fetchurl; };
|
||||
unpackdir = obj:
|
||||
lib.removeSuffix ".tgz"
|
||||
(lib.removeSuffix ".tar.gz" obj.name);
|
||||
|
||||
generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 }: let
|
||||
versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}";
|
||||
@ -32,12 +36,8 @@ let
|
||||
, autoreconfHook, bison, autoconf
|
||||
, darwin ? null
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version;
|
||||
|
||||
name = "ruby-${version}";
|
||||
|
||||
src = if useRailsExpress then fetchFromGitHub {
|
||||
let rubySrc =
|
||||
if useRailsExpress then fetchFromGitHub {
|
||||
owner = "ruby";
|
||||
repo = "ruby";
|
||||
rev = tag;
|
||||
@ -46,6 +46,18 @@ let
|
||||
url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${fullVersionName}.tar.gz";
|
||||
sha256 = sha256.src;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version;
|
||||
|
||||
name = "ruby-${version}";
|
||||
|
||||
srcs = [ rubySrc rubygemsSrc ];
|
||||
sourceRoot =
|
||||
if useRailsExpress then
|
||||
"ruby-${tag}-src"
|
||||
else
|
||||
unpackdir rubySrc;
|
||||
|
||||
# Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
|
||||
NROFF = "${groff}/bin/nroff";
|
||||
@ -67,11 +79,15 @@ let
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
patches = (import ./patchsets.nix {
|
||||
inherit patchSet useRailsExpress ops patchLevel;
|
||||
})."${versionNoPatch}";
|
||||
patches =
|
||||
[ ./gem_hook.patch ] ++
|
||||
(import ./patchsets.nix {
|
||||
inherit patchSet useRailsExpress ops patchLevel;
|
||||
})."${versionNoPatch}";
|
||||
|
||||
postUnpack = opString isRuby21 ''
|
||||
postUnpack = ''
|
||||
cp -r ${unpackdir rubygemsSrc} ${sourceRoot}/rubygems
|
||||
'' + opString isRuby21 ''
|
||||
rm "$sourceRoot/enc/unicode/name2ctype.h"
|
||||
'';
|
||||
|
||||
@ -99,6 +115,11 @@ let
|
||||
installFlags = stdenv.lib.optionalString docSupport "install-doc";
|
||||
# Bundler tries to create this directory
|
||||
postInstall = ''
|
||||
# Update rubygems
|
||||
pushd rubygems
|
||||
$out/bin/ruby setup.rb
|
||||
popd
|
||||
|
||||
# Bundler tries to create this directory
|
||||
mkdir -pv $out/${passthru.gemPath}
|
||||
mkdir -p $out/nix-support
|
||||
@ -119,7 +140,7 @@ let
|
||||
|
||||
meta = {
|
||||
license = stdenv.lib.licenses.ruby;
|
||||
homepage = "http://www.ruby-lang.org/en/";
|
||||
homepage = http://www.ruby-lang.org/en/;
|
||||
description = "The Ruby language";
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
|
||||
diff --git a/rubygems/lib/rubygems/installer.rb b/rubygems/lib/rubygems/installer.rb
|
||||
index d1ef3cb..bf15652 100755
|
||||
--- a/lib/rubygems/installer.rb
|
||||
+++ b/lib/rubygems/installer.rb
|
||||
--- a/rubygems/lib/rubygems/installer.rb
|
||||
+++ b/rubygems/lib/rubygems/installer.rb
|
||||
@@ -545,6 +545,13 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
|
||||
|
||||
say path if Gem.configuration.really_verbose
|
||||
|
8
pkgs/development/interpreters/ruby/rubygems-src.nix
Normal file
8
pkgs/development/interpreters/ruby/rubygems-src.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{ fetchurl
|
||||
, version ? "2.4.8"
|
||||
, sha256 ? "0pl4civyf0vhqsqbqaivvxrb3fsg8sid9a8jv5vfnk4hypz3ahss"
|
||||
}:
|
||||
fetchurl {
|
||||
url = "http://production.cf.rubygems.org/rubygems/rubygems-${version}.tgz";
|
||||
sha256 = sha256;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
{ stdenv, lib, fetchurl, makeWrapper, ruby }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "rubygems-${version}";
|
||||
version = "2.4.8";
|
||||
src = fetchurl {
|
||||
url = "http://production.cf.rubygems.org/rubygems/${name}.tgz";
|
||||
sha256 = "0pl4civyf0vhqsqbqaivvxrb3fsg8sid9a8jv5vfnk4hypz3ahss";
|
||||
};
|
||||
|
||||
patches = [ ./gem_hook.patch ];
|
||||
|
||||
buildInputs = [ruby makeWrapper];
|
||||
|
||||
buildPhase = ":";
|
||||
|
||||
installPhase = ''
|
||||
ruby setup.rb --prefix=$out/
|
||||
|
||||
wrapProgram $out/bin/gem --prefix RUBYLIB : $out/lib
|
||||
|
||||
find $out -type f -name "*.rb" |
|
||||
xargs sed -i "s@/usr/bin/env@$(type -p env)@g"
|
||||
|
||||
mkdir -pv $out/nix-support
|
||||
cat > $out/nix-support/setup-hook <<EOF
|
||||
export RUBYOPT=rubygems
|
||||
addToSearchPath RUBYLIB $out/lib
|
||||
EOF
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "A package management framework for Ruby";
|
||||
};
|
||||
}
|
@ -5611,8 +5611,6 @@ let
|
||||
ruby_2_2 = ruby_2_2_3;
|
||||
ruby_2_3 = ruby_2_3_0;
|
||||
|
||||
rubygems = hiPrio (callPackage ../development/interpreters/ruby/rubygems.nix {});
|
||||
|
||||
scsh = callPackage ../development/interpreters/scsh { };
|
||||
|
||||
scheme48 = callPackage ../development/interpreters/scheme48 { };
|
||||
@ -16517,6 +16515,7 @@ aliases = with self; rec {
|
||||
rdiff_backup = rdiff-backup; # added 2014-11-23
|
||||
rekonqWrapper = rekonq; # added 2015-01
|
||||
rssglx = rss-glx; #added 2015-03-25
|
||||
rubygems = throw "deprecated 2016-03-02: rubygems is now bundled with ruby";
|
||||
rxvt_unicode_with-plugins = rxvt_unicode-with-plugins; # added 2015-04-02
|
||||
samsungUnifiedLinuxDriver = samsung-unified-linux-driver; # added 2016-01-25
|
||||
saneBackends = sane-backends; # added 2016-01-02
|
||||
|
Loading…
Reference in New Issue
Block a user