buildBazelPackage: fix directory symlink handling

The previous behaviour would work fine as long as `symlink` is a link to
a file. If is a link to a directory though, the new `ln` wouldn't
overwrite it but would create a new link *in that directory* (with the
name of the link source).

Instead, we can precompute the target location, then first remove the
symlink and write the new one in its place.
This commit is contained in:
Timo Kaufmann 2019-06-20 18:35:16 +02:00
parent ac28607a03
commit 0cfd90a109

View file

@ -59,7 +59,9 @@ in stdenv.mkDerivation (fBuildAttrs // {
# Patching symlinks to remove build directory reference
find $bazelOut/external -type l | while read symlink; do
ln -sf $(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,") "$symlink"
new_target="$(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,")"
rm "$symlink"
ln -sf "$new_target" "$symlink"
done
cp -r $bazelOut/external $out