mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 07:00:43 +00:00
pleasant ruby
This commit is contained in:
parent
a8492fd636
commit
794740b7e3
|
@ -1,62 +1,93 @@
|
|||
{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;
|
||||
|
||||
installPhase = ''
|
||||
export HOME=$TMP/home; mkdir -pv "$HOME"
|
||||
preCheckGit = ruby.stdenv.lib.optionalString doGitPrecheckHack ''
|
||||
${git}/bin/git init
|
||||
${git}/bin/git add .
|
||||
'';
|
||||
|
||||
gem install -V --ignore-dependencies \
|
||||
-i "$out/${ruby.gemPath}" -n "$out/bin" "$src" $gemFlags -- $buildFlags
|
||||
rm -frv $out/${ruby.gemPath}/cache # don't keep the .gem file here
|
||||
preCheck = ''
|
||||
cd gem-build/*
|
||||
OLD_PATH="$GEM_PATH"
|
||||
export GEM_PATH="${depsPath}"
|
||||
'' + preCheck;
|
||||
|
||||
addToSearchPath GEM_PATH $out/${ruby.gemPath}
|
||||
postCheck = ''
|
||||
GEM_PATH="$OLD_PATH"
|
||||
'' + postCheck;
|
||||
|
||||
for prog in $out/bin/*; do
|
||||
wrapProgram "$prog" \
|
||||
--prefix GEM_PATH : "$GEM_PATH" \
|
||||
--prefix RUBYLIB : "${rubygems}/lib" \
|
||||
--set RUBYOPT rubygems \
|
||||
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
|
||||
done
|
||||
|
||||
for prog in $out/gems/*/bin/*; do
|
||||
[[ -e "$out/bin/$(basename $prog)" ]]
|
||||
done
|
||||
|
||||
# looks like useless files which break build repeatability and consume space
|
||||
rm $out/${ruby.gemPath}/doc/*/*/created.rid || true
|
||||
rm $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true
|
||||
|
||||
runHook postInstall
|
||||
checkPhase =
|
||||
if attrs ? checkPhase then attrs.checkPhase
|
||||
else ''
|
||||
runHook preCheckGit
|
||||
runHook preCheck
|
||||
test -f Rakefile && ${rake}/bin/rake ${testTask} -v
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
propagatedUserEnvPkgs = requiredGems;
|
||||
installPhase = ''
|
||||
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
|
||||
|
||||
passthru.isRubyGem = true;
|
||||
for prog in $out/bin/*; do
|
||||
wrapProgram "$prog" \
|
||||
--prefix GEM_PATH : "$out/${ruby.gemPath}:${depsPath}" \
|
||||
--prefix RUBYLIB : "${rubygems}/lib" \
|
||||
--set RUBYOPT rubygems \
|
||||
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
|
||||
done
|
||||
|
||||
};
|
||||
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
|
||||
for prog in $out/gems/*/bin/*; do
|
||||
[[ -e "$out/bin/$(basename $prog)" ]]
|
||||
done
|
||||
|
||||
# looks like useless files which break build repeatability and consume space
|
||||
rm $out/${ruby.gemPath}/doc/*/*/created.rid || true
|
||||
rm $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = gemPath;
|
||||
propagatedUserEnvPkgs = gemPath;
|
||||
|
||||
passthru.isRubyGem = true;
|
||||
inherit meta;
|
||||
})
|
||||
|
|
70
pkgs/development/interpreters/ruby/gems.nix
Normal file
70
pkgs/development/interpreters/ruby/gems.nix
Normal 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;
|
||||
};
|
||||
}
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue