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 # Normal gem packages can be used outside of bundler; a binstub is created in
# $out/bin. # $out/bin.
{ lib, ruby, rubygems, bundler, fetchurl, fetchgit, makeWrapper, git, { lib, ruby, bundler, fetchurl, fetchgit, makeWrapper, git,
buildRubyGem, darwin buildRubyGem, darwin
} @ defs: } @ defs:
@ -54,9 +54,6 @@ lib.makeOverridable (
let let
shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'"; shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
rubygems = (attrs.rubygems or defs.rubygems).override {
inherit ruby;
};
src = attrs.src or ( src = attrs.src or (
if type == "gem" then if type == "gem" then
fetchurl { fetchurl {
@ -79,14 +76,14 @@ let
in in
stdenv.mkDerivation (attrs // { stdenv.mkDerivation (attrs // {
inherit ruby rubygems; inherit ruby;
inherit doCheck; inherit doCheck;
inherit dontBuild; inherit dontBuild;
inherit dontStrip; inherit dontStrip;
inherit type; inherit type;
buildInputs = [ buildInputs = [
ruby rubygems makeWrapper ruby makeWrapper
] ++ lib.optionals (type == "git") [ git bundler ] ] ++ lib.optionals (type == "git") [ git bundler ]
++ lib.optional stdenv.isDarwin darwin.libobjc ++ lib.optional stdenv.isDarwin darwin.libobjc
++ buildInputs; ++ buildInputs;

View File

@ -1,6 +1,5 @@
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib { stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
, callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem, buildEnv , callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem, buildEnv
, rubygems
, git , git
, makeWrapper , makeWrapper
, bundler , bundler
@ -28,10 +27,9 @@ let
); );
hasBundler = builtins.hasAttr "bundler" importedGemset; hasBundler = builtins.hasAttr "bundler" importedGemset;
bundler = if hasBundler then gems.bundler else defs.bundler.override (attrs: { inherit ruby; }); 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: gems = lib.flip lib.mapAttrs configuredGemset (name: attrs:
buildRubyGem ((removeAttrs attrs ["source"]) // attrs.source // { buildRubyGem ((removeAttrs attrs ["source"]) // attrs.source // {
inherit ruby rubygems; inherit ruby;
gemName = name; gemName = name;
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []); gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
})); }));
@ -45,7 +43,6 @@ let
cd $out cd $out
chmod +w Gemfile.lock chmod +w Gemfile.lock
source ${rubygems}/nix-support/setup-hook
export GEM_PATH=${bundler}/${ruby.gemPath} export GEM_PATH=${bundler}/${ruby.gemPath}
${ruby}/bin/ruby -rubygems -e \ ${ruby}/bin/ruby -rubygems -e \
"require 'bundler'; Bundler.definition.lock('Gemfile.lock')" "require 'bundler'; Bundler.definition.lock('Gemfile.lock')"
@ -56,8 +53,6 @@ let
paths = envPaths; paths = envPaths;
pathsToLink = [ "/lib" ]; pathsToLink = [ "/lib" ];
postBuild = '' postBuild = ''
source ${rubygems}/nix-support/setup-hook
${ruby}/bin/ruby ${./gen-bin-stubs.rb} \ ${ruby}/bin/ruby ${./gen-bin-stubs.rb} \
"${ruby}/bin/ruby" \ "${ruby}/bin/ruby" \
"${confFiles}/Gemfile" \ "${confFiles}/Gemfile" \

View File

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

View File

@ -1,6 +1,7 @@
{ stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub { stdenv, lib, fetchurl, fetchFromSavannah, fetchFromGitHub
, zlib, openssl, gdbm, ncurses, readline, groff, libyaml, libffi, autoreconfHook, bison , zlib, openssl, gdbm, ncurses, readline, groff, libyaml, libffi, autoreconfHook, bison
, autoconf, darwin ? null , autoconf, darwin ? null
, buildEnv, bundler, bundix
} @ args: } @ args:
let let
@ -9,6 +10,10 @@ let
opString = stdenv.lib.optionalString; opString = stdenv.lib.optionalString;
patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; }; patchSet = import ./rvm-patchsets.nix { inherit fetchFromGitHub; };
config = import ./config.nix { inherit fetchFromSavannah; }; 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 generic = { majorVersion, minorVersion, teenyVersion, patchLevel, sha256 }: let
versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}"; versionNoPatch = "${majorVersion}.${minorVersion}.${teenyVersion}";
@ -31,13 +36,10 @@ let
, libffi, fiddleSupport ? true , libffi, fiddleSupport ? true
, autoreconfHook, bison, autoconf , autoreconfHook, bison, autoconf
, darwin ? null , darwin ? null
, buildEnv, bundler, bundix
}: }:
stdenv.mkDerivation rec { let rubySrc =
inherit version; if useRailsExpress then fetchFromGitHub {
name = "ruby-${version}";
src = if useRailsExpress then fetchFromGitHub {
owner = "ruby"; owner = "ruby";
repo = "ruby"; repo = "ruby";
rev = tag; rev = tag;
@ -46,6 +48,18 @@ let
url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${fullVersionName}.tar.gz"; url = "http://cache.ruby-lang.org/pub/ruby/${majorVersion}.${minorVersion}/ruby-${fullVersionName}.tar.gz";
sha256 = sha256.src; 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. # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
NROFF = "${groff}/bin/nroff"; NROFF = "${groff}/bin/nroff";
@ -67,11 +81,15 @@ let
enableParallelBuilding = true; enableParallelBuilding = true;
patches = (import ./patchsets.nix { patches =
inherit patchSet useRailsExpress ops patchLevel; [ ./gem_hook.patch ] ++
})."${versionNoPatch}"; (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" rm "$sourceRoot/enc/unicode/name2ctype.h"
''; '';
@ -99,6 +117,11 @@ let
installFlags = stdenv.lib.optionalString docSupport "install-doc"; installFlags = stdenv.lib.optionalString docSupport "install-doc";
# Bundler tries to create this directory # Bundler tries to create this directory
postInstall = '' postInstall = ''
# Update rubygems
pushd rubygems
$out/bin/ruby setup.rb
popd
# Bundler tries to create this directory # Bundler tries to create this directory
mkdir -pv $out/${passthru.gemPath} mkdir -pv $out/${passthru.gemPath}
mkdir -p $out/nix-support mkdir -p $out/nix-support
@ -119,17 +142,21 @@ let
meta = { meta = {
license = stdenv.lib.licenses.ruby; license = stdenv.lib.licenses.ruby;
homepage = "http://www.ruby-lang.org/en/"; homepage = http://www.ruby-lang.org/en/;
description = "The Ruby language"; description = "The Ruby language";
platforms = stdenv.lib.platforms.all; platforms = stdenv.lib.platforms.all;
}; };
passthru = rec { passthru = rec {
inherit majorVersion minorVersion teenyVersion patchLevel; inherit majorVersion minorVersion teenyVersion patchLevel version;
rubyEngine = "ruby"; rubyEngine = "ruby";
baseRuby = baseruby; baseRuby = baseruby;
libPath = "lib/${rubyEngine}/${versionNoPatch}"; libPath = "lib/${rubyEngine}/${versionNoPatch}";
gemPath = "lib/${rubyEngine}/gems/${versionNoPatch}"; gemPath = "lib/${rubyEngine}/gems/${versionNoPatch}";
dev = import ./dev.nix {
inherit buildEnv bundler bundix;
ruby = self;
};
}; };
} }
) args; in 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 diff --git a/rubygems/lib/rubygems/installer.rb b/rubygems/lib/rubygems/installer.rb
index d1ef3cb..bf15652 100755 index a88d393..8612901 100644
--- a/lib/rubygems/installer.rb --- a/rubygems/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb +++ b/rubygems/lib/rubygems/installer.rb
@@ -545,6 +545,13 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')} @@ -766,7 +766,15 @@ TEXT
# Ensures that files can't be installed outside the gem directory.
say path if Gem.configuration.really_verbose def extract_files
end - @package.extract_files gem_dir
+ + ret = @package.extract_files gem_dir
+ if !ENV['NIX_POST_EXTRACT_FILES_HOOK'].nil? + if ENV['NIX_POST_EXTRACT_FILES_HOOK']
+ print "\nrunning NIX_POST_EXTRACT_FILES_HOOK #{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{@gem_dir}\n" + puts
+ print `#{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{@gem_dir}` + puts "running NIX_POST_EXTRACT_FILES_HOOK #{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{gem_dir}"
+ print "\nrunning NIX_POST_EXTRACT_FILES_HOOK done\n" + system("#{ENV['NIX_POST_EXTRACT_FILES_HOOK']} #{gem_dir}")
+ puts "running NIX_POST_EXTRACT_FILES_HOOK done"
+ puts
+ end + end
+ + ret
end 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_2 = ruby_2_2_3;
ruby_2_3 = ruby_2_3_0; ruby_2_3 = ruby_2_3_0;
rubygems = hiPrio (callPackage ../development/interpreters/ruby/rubygems.nix {});
scsh = callPackage ../development/interpreters/scsh { }; scsh = callPackage ../development/interpreters/scsh { };
scheme48 = callPackage ../development/interpreters/scheme48 { }; scheme48 = callPackage ../development/interpreters/scheme48 { };
@ -16530,6 +16528,7 @@ aliases = with self; rec {
rdiff_backup = rdiff-backup; # added 2014-11-23 rdiff_backup = rdiff-backup; # added 2014-11-23
rekonqWrapper = rekonq; # added 2015-01 rekonqWrapper = rekonq; # added 2015-01
rssglx = rss-glx; #added 2015-03-25 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 rxvt_unicode_with-plugins = rxvt_unicode-with-plugins; # added 2015-04-02
samsungUnifiedLinuxDriver = samsung-unified-linux-driver; # added 2016-01-25 samsungUnifiedLinuxDriver = samsung-unified-linux-driver; # added 2016-01-25
saneBackends = sane-backends; # added 2016-01-02 saneBackends = sane-backends; # added 2016-01-02