1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-29 00:54:11 +00:00

pleasant ruby

This commit is contained in:
Joel Taylor 2014-08-07 15:13:56 -07:00 committed by Charles Strahan
parent a8492fd636
commit 794740b7e3
4 changed files with 164 additions and 51 deletions

View file

@ -1,35 +1,74 @@
{stdenv, fetchurl, ruby, rubygems, makeWrapper, patches, overrides}:
{ ruby, fetchurl, rake, rubygemsFun, makeWrapper, lib, git }:
{ name
, namePrefix ? "ruby${ruby.majorVersion}" + "-"
, buildInputs ? []
, doCheck ? true
, doGitPrecheckHack ? false
, meta ? {}
, gemPath ? []
, testTask ? "test"
, preCheck ? ""
, postCheck ? ""
, ...} @ attrs:
let
gemDefaults = { name, basename, requiredGems, sha256, meta }:
{
buildInputs = [rubygems ruby makeWrapper];
unpackPhase = ":";
configurePhase=":";
bulidPhase=":";
rubygems = rubygemsFun ruby;
depsPath = lib.concatStringsSep ":" (map (g: "${g}/${ruby.gemPath}") gemPath);
src = fetchurl {
url = "http://rubygems.org/downloads/${name}.gem";
inherit sha256;
in ruby.stdenv.mkDerivation (attrs // {
inherit doCheck;
buildInputs = [ rubygems makeWrapper git ] ++ buildInputs;
name = namePrefix + name;
src = if attrs ? src
then attrs.src
else fetchurl {
url = "http://rubygems.org/downloads/${attrs.name}.gem";
inherit (attrs) sha256;
};
name = "ruby-${name}";
unpackPhase = ''
gem unpack $src --target=gem-build
'';
propagatedBuildInputs = requiredGems;
inherit meta;
dontBuild = true;
preCheckGit = ruby.stdenv.lib.optionalString doGitPrecheckHack ''
${git}/bin/git init
${git}/bin/git add .
'';
preCheck = ''
cd gem-build/*
OLD_PATH="$GEM_PATH"
export GEM_PATH="${depsPath}"
'' + preCheck;
postCheck = ''
GEM_PATH="$OLD_PATH"
'' + postCheck;
checkPhase =
if attrs ? checkPhase then attrs.checkPhase
else ''
runHook preCheckGit
runHook preCheck
test -f Rakefile && ${rake}/bin/rake ${testTask} -v
runHook postCheck
'';
installPhase = ''
export HOME=$TMP/home; mkdir -pv "$HOME"
gem install -V --ignore-dependencies \
-i "$out/${ruby.gemPath}" -n "$out/bin" "$src" $gemFlags -- $buildFlags
GEM_PATH="${depsPath}" GEM_HOME=$out/${ruby.gemPath} \
gem install -p http://nodtd.invalid \
--build-root / -n "$out/bin" "$src" $gemFlags -- $buildFlags
rm -frv $out/${ruby.gemPath}/cache # don't keep the .gem file here
addToSearchPath GEM_PATH $out/${ruby.gemPath}
for prog in $out/bin/*; do
wrapProgram "$prog" \
--prefix GEM_PATH : "$GEM_PATH" \
--prefix GEM_PATH : "$out/${ruby.gemPath}:${depsPath}" \
--prefix RUBYLIB : "${rubygems}/lib" \
--set RUBYOPT rubygems \
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
@ -46,17 +85,9 @@ let
runHook postInstall
'';
propagatedUserEnvPkgs = requiredGems;
propagatedBuildInputs = gemPath;
propagatedUserEnvPkgs = gemPath;
passthru.isRubyGem = true;
};
mb = stdenv.lib.maybeAttr;
patchedGem = a: stdenv.mkDerivation (removeAttrs (stdenv.lib.mergeAttrsByFuncDefaults
([ (gemDefaults a) ]
++ (stdenv.lib.concatMap (p: [(mb a.basename {} p) (mb a.name {} p)] )
patches)))
[ "mergeAttrBy" ]);
in
aName: a@{ name, basename, requiredGems, sha256, meta }:
stdenv.lib.foldl (d: o: mb name (mb basename d o) o) (patchedGem a) overrides
inherit meta;
})

View file

@ -0,0 +1,70 @@
{ ruby, callPackage }:
let
buildRubyGem = callPackage ./gem.nix { inherit ruby; };
in rec {
inherit buildRubyGem;
builder = buildRubyGem {
name = "builder-3.2.2";
sha256 = "14fii7ab8qszrvsvhz6z2z3i4dw0h41a62fjr2h1j8m41vbrmyv2";
doCheck = false;
};
bundler = buildRubyGem {
name = "bundler-1.6.5";
sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
dontPatchShebangs = 1;
checkPhase = ":";
};
capistrano = buildRubyGem {
name = "capistrano-3.2.1";
sha256 = "0jcx8jijbvl05pjd7jrzb1sf968vjzpvb190d1kfa968hfc92lm0";
gemPath = [ colorize i18n net_scp net_ssh rake sshkit ];
doCheck = false;
};
colorize = buildRubyGem {
name = "colorize-0.7.3";
sha256 = "0hccxpn0gryhdpyymkr7fnv2khz051f5rpw4xyrp9dr53b7yv3v2";
};
i18n = buildRubyGem {
name = "i18n-0.6.11";
sha256 = "0fwjlgmgry2blf8zlxn9c555cf4a16p287l599kz5104ncjxlzdk";
};
json = buildRubyGem {
name = "json-1.8.1";
sha256 = "0002bsycvizvkmk1jyv8px1hskk6wrjfk4f7x5byi8gxm6zzn6wn";
doCheck = false;
};
net_scp = buildRubyGem {
name = "net-scp-1.2.1";
sha256 = "0b0jqrcsp4bbi4n4mzyf70cp2ysyp6x07j8k8cqgxnvb4i3a134j";
gemPath = [ net_ssh ];
doCheck = false;
};
net_ssh = buildRubyGem {
name = "net-ssh-2.9.1";
sha256 = "1vscp4r58jisiigqc6d6752w19m1m6hmi3jkzmp3ydxai7h3jb2j";
doCheck = false;
};
rake = buildRubyGem {
name = "rake-10.3.2";
sha256 = "0nvpkjrpsk8xxnij2wd1cdn6arja9q11sxx4aq4fz18bc6fss15m";
gemPath = [ bundler ];
checkPhase = ":";
};
sshkit = buildRubyGem {
name = "sshkit-1.5.1";
sha256 = "0lyd77b43dh897lx8iqdm9284ara7076nahmlis33qkfjfs105dy";
gemPath = [ bundler colorize net_scp net_ssh ];
doGitPrecheckHack = true;
};
}

View file

@ -1,10 +1,10 @@
args : with args;
rec {
version = "1.8.25";
version = "2.4.1";
src = fetchurl {
url = "http://production.cf.rubygems.org/rubygems/${name}.tgz";
sha256 = "1j0wiy829nsfrpdzr9xzs39jf1lga3f5b7773vxqfs3lz3fli4v4";
sha256 = "0cpr6cx3h74ykpb0cp4p4xg7a8j0bhz3sk271jq69l4mm4zy4h4f";
};
buildInputs = [ruby makeWrapper];

View file

@ -4045,7 +4045,19 @@ let
ruby_2_0 = ruby_2_0_0;
ruby_2_1 = ruby_2_1_3;
rubyLibs = recurseIntoAttrs (callPackage ../development/interpreters/ruby/libs.nix { });
ruby18Libs = callPackage ../development/interpreters/ruby/gems.nix {
ruby = ruby18;
};
ruby19Libs = callPackage ../development/interpreters/ruby/gems.nix {
ruby = ruby19;
};
ruby2Libs = callPackage ../development/interpreters/ruby/gems.nix {
ruby = ruby2;
};
rubyLibs = ruby19Libs;
rake = rubyLibs.rake;