summary refs log tree commit diff
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
parentac28607a039eb8d04f756265d6ead55efea4c27f (diff)
downloadnixpkgs-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar
nixpkgs-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.gz
nixpkgs-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.bz2
nixpkgs-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.lz
nixpkgs-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.xz
nixpkgs-0cfd90a1091888a49e08b3acf8df8045ff528db7.tar.zst
nixpkgs-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.
-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 b0840192ece..37cee98a316 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