about summary refs log tree commit diff
path: root/pkgs/build-support/rust/hooks
diff options
context:
space:
mode:
authorfigsoda <figsoda@pm.me>2023-02-26 11:51:55 -0500
committerfigsoda <figsoda@pm.me>2023-02-26 11:55:50 -0500
commit3e18607be38fe5294fc4773220f25452ce0b7f9f (patch)
tree1e09e85597e4c9ea983390841d013212961de20b /pkgs/build-support/rust/hooks
parente5fb0c0c7236189f651dc607043592b405676617 (diff)
rustPlatform.cargoSetupHook: dereference symlinks in cargoDeps
unpackFile doesn't dereference symlinks if cargoDeps is a directory, and
some cargo builds run into permission issues because the files the
symlinks point to are not writable.
Diffstat (limited to 'pkgs/build-support/rust/hooks')
-rw-r--r--pkgs/build-support/rust/hooks/cargo-setup-hook.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
index 90a81d68b5200..42c05e42b0b86 100644
--- a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
+++ b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
@@ -8,7 +8,13 @@ cargoSetupPostUnpackHook() {
     # it writable. If we're using a tarball, the unpackFile hook already handles
     # this for us automatically.
     if [ -z $cargoVendorDir ]; then
-        unpackFile "$cargoDeps"
+        if [ -d "$cargoDeps" ]; then
+            local dest=$(stripHash "$cargoDeps")
+            cp -Lr --reflink=auto -- "$cargoDeps" "$dest"
+            chmod -R +644 -- "$dest"
+        else
+            unpackFile "$cargoDeps"
+        fi
         export cargoDepsCopy="$(realpath "$(stripHash $cargoDeps)")"
     else
         cargoDepsCopy="$(realpath "$(pwd)/$sourceRoot/${cargoRoot:+$cargoRoot/}${cargoVendorDir}")"