From 0cfd90a1091888a49e08b3acf8df8045ff528db7 Mon Sep 17 00:00:00 2001 From: Timo Kaufmann Date: Thu, 20 Jun 2019 18:35:16 +0200 Subject: 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. --- pkgs/build-support/build-bazel-package/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkgs/build-support') 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 -- cgit 1.4.1