2011-01-21 09:25:11 +01:00
|
|
|
{stdenv, fetchurl, ruby, rubygems, makeWrapper, patches, overrides}:
|
2011-01-21 09:25:02 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
gemDefaults = { name, basename, requiredGems, sha256, meta }:
|
|
|
|
{
|
|
|
|
buildInputs = [rubygems ruby makeWrapper];
|
|
|
|
unpackPhase = ":";
|
|
|
|
configurePhase=":";
|
|
|
|
bulidPhase=":";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://rubygems.org/downloads/${name}.gem";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
name = "ruby-${name}";
|
|
|
|
|
|
|
|
propagatedBuildInputs = requiredGems;
|
|
|
|
inherit meta;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
export HOME=$TMP/home; mkdir -pv "$HOME"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
addToSearchPath GEM_PATH $out/${ruby.gemPath}
|
|
|
|
|
|
|
|
for prog in $out/bin/*; do
|
|
|
|
wrapProgram "$prog" \
|
|
|
|
--prefix GEM_PATH : "$GEM_PATH" \
|
|
|
|
--prefix RUBYLIB : "${rubygems}/lib" \
|
2012-02-26 12:10:00 +01:00
|
|
|
--set RUBYOPT rubygems \
|
|
|
|
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
|
2011-01-21 09:25:02 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
for prog in $out/gems/*/bin/*; do
|
|
|
|
[[ -e "$out/bin/$(basename $prog)" ]]
|
|
|
|
done
|
|
|
|
|
2013-06-21 17:18:29 +02:00
|
|
|
# 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
|
|
|
|
|
2011-01-21 09:25:02 +01:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2012-02-17 22:40:14 +01:00
|
|
|
|
|
|
|
propagatedUserEnvPkgs = requiredGems;
|
|
|
|
|
2013-02-06 01:08:04 +01:00
|
|
|
passthru.isRubyGem = true;
|
|
|
|
|
2011-01-21 09:25:02 +01:00
|
|
|
};
|
|
|
|
mb = stdenv.lib.maybeAttr;
|
2011-01-21 09:25:11 +01:00
|
|
|
patchedGem = a: stdenv.mkDerivation (removeAttrs (stdenv.lib.mergeAttrsByFuncDefaults
|
|
|
|
([ (gemDefaults a) ]
|
|
|
|
++ (stdenv.lib.concatMap (p: [(mb a.basename {} p) (mb a.name {} p)] )
|
|
|
|
patches)))
|
|
|
|
[ "mergeAttrBy" ]);
|
2011-01-21 09:25:02 +01:00
|
|
|
in
|
|
|
|
aName: a@{ name, basename, requiredGems, sha256, meta }:
|
2011-01-21 09:25:11 +01:00
|
|
|
stdenv.lib.foldl (d: o: mb name (mb basename d o) o) (patchedGem a) overrides
|