From 3e18607be38fe5294fc4773220f25452ce0b7f9f Mon Sep 17 00:00:00 2001 From: figsoda Date: Sun, 26 Feb 2023 11:51:55 -0500 Subject: [PATCH] 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. --- pkgs/build-support/rust/hooks/cargo-setup-hook.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh index 90a81d68b520..42c05e42b0b8 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}")"