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.
This commit is contained in:
figsoda 2023-02-26 11:51:55 -05:00
parent e5fb0c0c72
commit 3e18607be3

View File

@ -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}")"