Merge pull request #13601 from zimbatm/ruby-dev

ruby.dev
This commit is contained in:
zimbatm 2016-03-18 19:05:45 +00:00
commit 9c4b45fafe
9 changed files with 94 additions and 76 deletions

View File

@ -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;

View File

@ -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" \

View File

@ -4,7 +4,7 @@ buildRubyGem rec {
inherit ruby;
name = "${gemName}-${version}";
gemName = "bundler";
version = "1.10.6";
sha256 = "1vlzfq0bkkj4jyq6av0y55mh5nj5n0f3mfbmmifwgkh44g8k6agv";
version = "1.11.2";
sha256 = "0s37j1hyngc4shq0in8f9y1knjdqkisdg3dd1mfwgq7n1bz8zan7";
dontPatchShebangs = true;
}

View File

@ -1,6 +1,7 @@
{ stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub
, zlib, openssl, gdbm, ncurses, readline, groff, libyaml, libffi, autoreconfHook, bison
, autoconf, darwin ? null
, buildEnv, bundler, bundix
} @ args:
let
@ -9,6 +10,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}";
@ -31,13 +36,10 @@ let
, libffi, fiddleSupport ? true
, autoreconfHook, bison, autoconf
, darwin ? null
, buildEnv, bundler, bundix
}:
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 +48,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 +81,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 +117,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,17 +142,21 @@ 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;
};
passthru = rec {
inherit majorVersion minorVersion teenyVersion patchLevel;
inherit majorVersion minorVersion teenyVersion patchLevel version;
rubyEngine = "ruby";
baseRuby = baseruby;
libPath = "lib/${rubyEngine}/${versionNoPatch}";
gemPath = "lib/${rubyEngine}/gems/${versionNoPatch}";
dev = import ./dev.nix {
inherit buildEnv bundler bundix;
ruby = self;
};
};
}
) args; in self;

View File

@ -0,0 +1,24 @@
/* An environment for development that bundles ruby, bundler and bundix
together. This avoids version conflicts where each is using a diferent
version of each-other.
*/
{ buildEnv, ruby, bundler, bundix }:
let
bundler_ = bundler.override {
ruby = ruby;
};
bundix_ = bundix.override {
ruby = ruby;
bundler = bundler_;
};
in
buildEnv {
name = "${ruby.rubyEngine}-dev-${ruby.version}";
paths = [
bundix_
bundler_
ruby
];
pathsToLink = [ "/bin" ];
ignoreCollisions = true;
}

View File

@ -1,18 +1,21 @@
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index d1ef3cb..bf15652 100755
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -545,6 +545,13 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
diff --git a/rubygems/lib/rubygems/installer.rb b/rubygems/lib/rubygems/installer.rb
index a88d393..8612901 100644
--- a/rubygems/lib/rubygems/installer.rb
+++ b/rubygems/lib/rubygems/installer.rb
@@ -766,7 +766,15 @@ TEXT
# Ensures that files can't be installed outside the gem directory.
say path if Gem.configuration.really_verbose
end
+
+ if !ENV['NIX_POST_EXTRACT_FILES_HOOK'].nil?
+ print "\nrunning NIX_POST_EXTRACT_FILES_HOOK #{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{@gem_dir}\n"
+ print `#{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{@gem_dir}`
+ print "\nrunning NIX_POST_EXTRACT_FILES_HOOK done\n"
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}")
+ puts "running NIX_POST_EXTRACT_FILES_HOOK done"
+ puts
+ end
+
+ ret
end
##

View File

@ -0,0 +1,8 @@
{ fetchurl
, version ? "2.6.2"
, sha256 ? "1j02ajici555f35vd6ky6m4bxs8lh8nqb1c59qqib4jp4ibcv6zy"
}:
fetchurl {
url = "http://production.cf.rubygems.org/rubygems/rubygems-${version}.tgz";
sha256 = sha256;
}

View File

@ -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";
};
}

View File

@ -5609,8 +5609,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 { };
@ -16530,6 +16528,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