Improve buildRubyGem
This commit is contained in:
parent
f4d5fa4da6
commit
2cb31d576a
@ -9,7 +9,7 @@
|
|||||||
gems = rubyLibs.importGems gemset (config.gemOverrides or (gemset: {}));
|
gems = rubyLibs.importGems gemset (config.gemOverrides or (gemset: {}));
|
||||||
in {
|
in {
|
||||||
inherit ruby; # TODO: Set ruby using expr.rubyVersion if not given.
|
inherit ruby; # TODO: Set ruby using expr.rubyVersion if not given.
|
||||||
gemPath = map (drv: "${drv}/${ruby.gemPath}") (
|
gemPath = map (drv: "${drv}") (
|
||||||
builtins.filter (value: lib.isDerivation value) (lib.attrValues gems)
|
builtins.filter (value: lib.isDerivation value) (lib.attrValues gems)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -36,15 +36,11 @@ let
|
|||||||
then (builtins.getAttr name fixes) attrs
|
then (builtins.getAttr name fixes) attrs
|
||||||
else {};
|
else {};
|
||||||
in
|
in
|
||||||
buildRubyGem ({
|
buildRubyGem (attrs // {
|
||||||
name = attrs.name;
|
|
||||||
sha256 = attrs.sha256;
|
|
||||||
inherit gemPath;
|
inherit gemPath;
|
||||||
# Disable the checkPhase as there no single way to run tests for a given
|
# Disable the checkPhase as there no single way to run tests for a given
|
||||||
# gem: https://github.com/rubygems/rubygems/issues/730
|
# gem: https://github.com/rubygems/rubygems/issues/730
|
||||||
checkPhase = ":";
|
checkPhase = ":";
|
||||||
# Gems downloaded from rubygems.org don't need to be built again.
|
|
||||||
dontBuild = true;
|
|
||||||
} // fix)
|
} // fix)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -70,9 +66,9 @@ let
|
|||||||
therubyracer = attrs: {
|
therubyracer = attrs: {
|
||||||
dontBuild = false;
|
dontBuild = false;
|
||||||
|
|
||||||
preBuild = ''
|
preInstall = ''
|
||||||
addToSearchPath RUBYLIB "${gems.libv8}/${ruby.gemPath}/gems/libv8-3.16.14.3/lib"
|
addToSearchPath RUBYLIB "${gems.libv8}/gems/libv8-3.16.14.3/lib"
|
||||||
addToSearchPath RUBYLIB "${gems.libv8}/${ruby.gemPath}/gems/libv8-3.16.14.3/ext"
|
addToSearchPath RUBYLIB "${gems.libv8}/gems/libv8-3.16.14.3/ext"
|
||||||
ln -s ${clang}/bin/clang $TMPDIR/gcc
|
ln -s ${clang}/bin/clang $TMPDIR/gcc
|
||||||
ln -s ${clang}/bin/clang++ $TMPDIR/g++
|
ln -s ${clang}/bin/clang++ $TMPDIR/g++
|
||||||
export PATH=$TMPDIR:$PATH
|
export PATH=$TMPDIR:$PATH
|
||||||
|
@ -27,16 +27,24 @@ in ruby.stdenv.mkDerivation (attrs // {
|
|||||||
inherit (attrs) sha256;
|
inherit (attrs) sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
unpackPhase = ''
|
# The source is expected to either be a gem package or a directory.
|
||||||
if test -d $src; then
|
#
|
||||||
cd $src
|
# - Gem packages are already built, so they don't even need to be unpacked.
|
||||||
|
# They will skip the buildPhase.
|
||||||
|
# - A directory containing the sources will need to go through all of the
|
||||||
|
# usual phases.
|
||||||
|
unpackPhase= ''
|
||||||
|
gemRegex="\.gem"
|
||||||
|
if [[ $src =~ $gemRegex ]]
|
||||||
|
then
|
||||||
|
runHook preUnpack
|
||||||
|
echo "Source is a gem package, won't unpack."
|
||||||
|
gempkg=$src
|
||||||
|
dontBuild=1
|
||||||
|
runHook postUnpack
|
||||||
else
|
else
|
||||||
cp $src ${attrs.name}.gem
|
# Fall back to the original thing for everything else.
|
||||||
gem unpack ${attrs.name}.gem
|
unpackPhase
|
||||||
rm ${attrs.name}.gem
|
|
||||||
mv ${attrs.name} gem-build
|
|
||||||
cd gem-build
|
|
||||||
sourceRoot=`pwd`
|
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@ -46,6 +54,23 @@ in ruby.stdenv.mkDerivation (attrs // {
|
|||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
# TODO: Investigate. The complete working tree is touched by fetchgit.
|
||||||
|
if [ -d .git ]; then
|
||||||
|
git reset
|
||||||
|
fi
|
||||||
|
|
||||||
|
gemspec=`find . -name '*.gemspec'`
|
||||||
|
output=`gem build $gemspec`
|
||||||
|
gempkg=`echo $output|grep -oP 'File: \K(.*)'`
|
||||||
|
|
||||||
|
echo "Gem package built: $gempkg"
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
@ -54,7 +79,7 @@ in ruby.stdenv.mkDerivation (attrs // {
|
|||||||
# separate buildPhase.
|
# separate buildPhase.
|
||||||
# --ignore-dependencies is necessary as rubygems otherwise always
|
# --ignore-dependencies is necessary as rubygems otherwise always
|
||||||
# connects to the repository, thus breaking pure builds.
|
# connects to the repository, thus breaking pure builds.
|
||||||
GEM_HOME=$out/${ruby.gemPath} \
|
GEM_HOME=$out \
|
||||||
gem install \
|
gem install \
|
||||||
--local \
|
--local \
|
||||||
--force \
|
--force \
|
||||||
@ -63,30 +88,26 @@ in ruby.stdenv.mkDerivation (attrs // {
|
|||||||
--build-root "/" \
|
--build-root "/" \
|
||||||
--bindir "$out/bin" \
|
--bindir "$out/bin" \
|
||||||
--backtrace \
|
--backtrace \
|
||||||
$src $gemFlags -- $buildFlags
|
$gempkg $gemFlags -- $buildFlags
|
||||||
|
|
||||||
rm -frv $out/${ruby.gemPath}/cache # don't keep the .gem file here
|
rm -frv $out/cache # don't keep the .gem file here
|
||||||
|
|
||||||
for prog in $out/bin/*; do
|
for prog in $out/bin/*; do
|
||||||
wrapProgram "$prog" \
|
wrapProgram "$prog" \
|
||||||
--prefix GEM_PATH : "$out/${ruby.gemPath}:$GEM_PATH" \
|
--prefix GEM_PATH : "$out:$GEM_PATH" \
|
||||||
--prefix RUBYLIB : "${rubygems}/lib" \
|
--prefix RUBYLIB : "${rubygems}/lib" \
|
||||||
--set RUBYOPT rubygems \
|
--set RUBYOPT rubygems \
|
||||||
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
|
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
|
||||||
done
|
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
|
# looks like useless files which break build repeatability and consume space
|
||||||
rm -fv $out/${ruby.gemPath}/doc/*/*/created.rid || true
|
rm -fv $out/doc/*/*/created.rid || true
|
||||||
rm -fv $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true
|
rm -fv $out/gems/*/ext/*/mkmf.log || true
|
||||||
|
|
||||||
mkdir -p $out/nix-support
|
mkdir -p $out/nix-support
|
||||||
|
|
||||||
cat > $out/nix-support/setup-hook <<EOF
|
cat > $out/nix-support/setup-hook <<EOF
|
||||||
if [[ "$GEM_PATH" != *$out/${ruby.gemPath}* ]]; then
|
if [[ "$GEM_PATH" != *$out* ]]; then
|
||||||
addToSearchPath GEM_PATH $out/${ruby.gemPath}
|
addToSearchPath GEM_PATH $out/${ruby.gemPath}
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user