ruby: various fixes

This commit is contained in:
Charles Strahan 2015-01-14 21:19:53 -05:00
parent aaa2e9705a
commit 1a1e6cfc04
2 changed files with 19 additions and 17 deletions

View File

@ -29,6 +29,8 @@ stdenv.mkDerivation (attrs // {
inherit (attrs) sha256; inherit (attrs) sha256;
}; };
phases = [ "unpackPhase" "patchPhase" "buildPhase" "checkPhase" "installPhase" "fixupPhase" ];
# The source is expected to either be a gem package or a directory. # The source is expected to either be a gem package or a directory.
# #
# - Gem packages are already built, so they don't even need to be unpacked. # - Gem packages are already built, so they don't even need to be unpacked.
@ -40,7 +42,7 @@ stdenv.mkDerivation (attrs // {
if [[ $src =~ $gemRegex ]] if [[ $src =~ $gemRegex ]]
then then
runHook preUnpack runHook preUnpack
echo "Source is a gem package, won't unpack." echo "source is a gem package, won't unpack"
gempkg=$src gempkg=$src
dontBuild=1 dontBuild=1
runHook postUnpack runHook postUnpack
@ -60,14 +62,20 @@ stdenv.mkDerivation (attrs // {
git reset git reset
fi fi
gemspec=`find . -name '*.gemspec'` gemspec=$(find . -name '*.gemspec')
output=`gem build $gemspec` echo "found the following gemspecs:"
echo "$gemspec"
gem build $gemspec | tee .output gemspec=$(echo "$gemspec" | head -n1)
gempkg=`cat .output | grep -oP 'File: \K(.*)'` echo "building $gemspec"
rm .output
echo "Gem package built: $gempkg" exec 3>&1
output=$(gem build $gemspec | tee >(cat - >&3))
exec 3>&-
gempkg=$(echo "$output" | grep -oP 'File: \K(.*)')
echo "gem package built: $gempkg"
runHook postBuild runHook postBuild
''; '';
@ -90,7 +98,9 @@ stdenv.mkDerivation (attrs // {
--backtrace \ --backtrace \
$gempkg $gemFlags -- $buildFlags $gempkg $gemFlags -- $buildFlags
rm -frv $out/${ruby.gemPath}/cache # don't keep the .gem file here # Yes, we really do need the $out/${ruby.gemPath}/cache.
# This is very important in order for many parts of RubyGems/Bundler to not blow up.
# See https://github.com/bundler/bundler/issues/3327
mkdir -p $out/bin mkdir -p $out/bin
for prog in $out/${ruby.gemPath}/gems/*/bin/*; do for prog in $out/${ruby.gemPath}/gems/*/bin/*; do
@ -113,14 +123,6 @@ stdenv.mkDerivation (attrs // {
fi fi
EOF EOF
# Copy the gem file to the cache.
# This is very important in order for many parts of Bundler to not blow up.
# See https://github.com/bundler/bundler/issues/3327
gemname=$(basename $out/${ruby.gemPath}/gems/*).gem
echo "caching $gemname"
mkdir $out/${ruby.gemPath}/cache
cp $gempkg $out/${ruby.gemPath}/cache/$gemname
runHook postInstall runHook postInstall
''; '';

View File

@ -37,7 +37,7 @@ let
inherit (attrs.src) sha256; inherit (attrs.src) sha256;
}; };
fetchers.git = attrs: fetchgit { fetchers.git = attrs: fetchgit {
inherit (attrs.src) url rev sha256; inherit (attrs.src) url rev sha256 fetchSubmodules;
leaveDotGit = true; leaveDotGit = true;
}; };