about summary refs log tree commit diff
path: root/pkgs/build-support/build-bazel-package
diff options
context:
space:
mode:
authorTimo Kaufmann <timokau@zoho.com>2019-06-20 18:35:16 +0200
committerTimo Kaufmann <timokau@zoho.com>2019-06-20 18:35:16 +0200
commit0cfd90a1091888a49e08b3acf8df8045ff528db7 (patch)
treedb1ba3a73cab436beb2df8dee13945a47a5ca406 /pkgs/build-support/build-bazel-package
parentac28607a039eb8d04f756265d6ead55efea4c27f (diff)
downloadnixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar
nixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.gz
nixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.bz2
nixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.lz
nixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.xz
nixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.zst
nixlib-0cfd90a1091888a49e08b3acf8df8045ff528db7.zip
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.
Diffstat (limited to 'pkgs/build-support/build-bazel-package')
-rw-r--r--pkgs/build-support/build-bazel-package/default.nix4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix
index b0840192ecec..37cee98a3160 100644
--- a/pkgs/build-support/build-bazel-package/default.nix
+++ b/pkgs/build-support/build-bazel-package/default.nix
@@ -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