2014-08-08 00:13:56 +02:00
|
|
|
{ ruby, fetchurl, rake, rubygemsFun, makeWrapper, lib, git }:
|
|
|
|
|
|
|
|
{ name
|
|
|
|
, namePrefix ? "ruby${ruby.majorVersion}" + "-"
|
|
|
|
, buildInputs ? []
|
2014-08-08 03:35:36 +02:00
|
|
|
, doCheck ? false
|
2014-08-08 00:13:56 +02:00
|
|
|
, doGitPrecheckHack ? false
|
|
|
|
, meta ? {}
|
|
|
|
, gemPath ? []
|
|
|
|
, testTask ? "test"
|
|
|
|
, preCheck ? ""
|
|
|
|
, postCheck ? ""
|
|
|
|
, ...} @ attrs:
|
2011-01-21 09:25:02 +01:00
|
|
|
|
|
|
|
let
|
2014-08-08 00:13:56 +02:00
|
|
|
rubygems = rubygemsFun ruby;
|
|
|
|
depsPath = lib.concatStringsSep ":" (map (g: "${g}/${ruby.gemPath}") gemPath);
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
in ruby.stdenv.mkDerivation (attrs // {
|
|
|
|
inherit doCheck;
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
buildInputs = [ rubygems makeWrapper git ] ++ buildInputs;
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
name = namePrefix + name;
|
|
|
|
|
|
|
|
src = if attrs ? src
|
|
|
|
then attrs.src
|
|
|
|
else fetchurl {
|
|
|
|
url = "http://rubygems.org/downloads/${attrs.name}.gem";
|
|
|
|
inherit (attrs) sha256;
|
|
|
|
};
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
unpackPhase = ''
|
|
|
|
gem unpack $src --target=gem-build
|
|
|
|
'';
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
dontBuild = true;
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
preCheckGit = ruby.stdenv.lib.optionalString doGitPrecheckHack ''
|
|
|
|
${git}/bin/git init
|
|
|
|
${git}/bin/git add .
|
|
|
|
'';
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
preCheck = ''
|
|
|
|
cd gem-build/*
|
|
|
|
OLD_PATH="$GEM_PATH"
|
|
|
|
export GEM_PATH="${depsPath}"
|
|
|
|
'' + preCheck;
|
2011-01-21 09:25:02 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
postCheck = ''
|
|
|
|
GEM_PATH="$OLD_PATH"
|
|
|
|
'' + postCheck;
|
2013-06-21 17:18:29 +02:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
checkPhase =
|
|
|
|
if attrs ? checkPhase then attrs.checkPhase
|
|
|
|
else ''
|
|
|
|
runHook preCheckGit
|
|
|
|
runHook preCheck
|
|
|
|
test -f Rakefile && ${rake}/bin/rake ${testTask} -v
|
|
|
|
runHook postCheck
|
2011-01-21 09:25:02 +01:00
|
|
|
'';
|
2012-02-17 22:40:14 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
installPhase = ''
|
2014-08-08 03:53:17 +02:00
|
|
|
GEM_HOME=$out/${ruby.gemPath} \
|
2014-08-08 00:13:56 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
for prog in $out/bin/*; do
|
|
|
|
wrapProgram "$prog" \
|
2014-08-08 03:53:17 +02:00
|
|
|
--prefix GEM_PATH : "$out/${ruby.gemPath}" \
|
2014-08-08 00:13:56 +02:00
|
|
|
--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
|
|
|
|
|
2014-08-08 03:46:17 +02:00
|
|
|
mkdir -p $out/nix-support
|
|
|
|
|
|
|
|
cat > $out/nix-support/setup-hook <<EOF
|
|
|
|
addToSearchPath GEM_PATH $out/${ruby.gemPath}
|
|
|
|
EOF
|
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2012-02-17 22:40:14 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
propagatedBuildInputs = gemPath;
|
|
|
|
propagatedUserEnvPkgs = gemPath;
|
2013-02-06 01:08:04 +01:00
|
|
|
|
2014-08-08 00:13:56 +02:00
|
|
|
passthru.isRubyGem = true;
|
|
|
|
inherit meta;
|
|
|
|
})
|