From c72bae8641d4486b3bd7b556d577df519f640f9a Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Tue, 25 Apr 2023 19:10:08 +0200 Subject: [PATCH 1/2] Handle Darwin too w.r.t. SYSROOT detection fix --- rust-overlay.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rust-overlay.nix b/rust-overlay.nix index fb862ec..4a35470 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -289,19 +289,20 @@ let cp --remove-destination "$(realpath -e $target)" $target fi - # The SYSROOT is determined by using the librustc_driver-*.so. + # The SYSROOT is determined by using the librustc_driver-*.{so,dylib}. # So, we need to point to the *.so files in our derivation. - chmod u+w $target - patchelf --set-rpath "$out/lib" $target || true + shopt -u nullglob + if ls $out/lib/*.so &>/dev/null; then + chmod u+w $target + patchelf --set-rpath "$out/lib" $target || true + fi done - # Here we copy the librustc_driver-*.so to our derivation. + # Here we copy the librustc_driver-*.{so,dylib} to our derivation. # The SYSROOT is determined based on the path of this library. - if ls $out/lib/librustc_driver-*.so &> /dev/null; then - RUSTC_DRIVER_PATH=$(realpath -e $out/lib/librustc_driver-*.so) - rm $out/lib/librustc_driver-*.so - cp $RUSTC_DRIVER_PATH $out/lib/ - fi + shopt -s nullglob + RUSTC_DRIVER_PATH=$(realpath -e $out/lib/librustc_driver-*.{so,dylib}) + cp --remove-destination $RUSTC_DRIVER_PATH $out/lib/ ''; # Export the manifest file as part of the nix-support files such From 1ca9ee7192f973fd67b0988bdd77b8c11ae245a6 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Mon, 31 Jul 2023 23:06:35 +0200 Subject: [PATCH 2/2] use `stdenv.hostPlatform.extensions.sharedLibrary` to remove duplicated copying this is review feedback, thanks! --- rust-overlay.nix | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rust-overlay.nix b/rust-overlay.nix index 43f1871..b55f56f 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -297,12 +297,8 @@ let # Here we copy the librustc_driver-*.{so,dylib} to our derivation. # The SYSROOT is determined based on the path of this library. - if test "" != $out/lib/librustc_driver-*.so &> /dev/null; then - RUSTC_DRIVER_PATH=$(realpath -e $out/lib/librustc_driver-*.so) - cp --remove-destination $RUSTC_DRIVER_PATH $out/lib/ - fi - if test "" != $out/lib/librustc_driver-*.dylib &> /dev/null; then - RUSTC_DRIVER_PATH=$(realpath -e $out/lib/librustc_driver-*.dylib) + if test "" != $out/lib/librustc_driver-*${stdenv.hostPlatform.extensions.sharedLibrary} &> /dev/null; then + RUSTC_DRIVER_PATH=$(realpath -e $out/lib/librustc_driver-*${stdenv.hostPlatform.extensions.sharedLibrary}) cp --remove-destination $RUSTC_DRIVER_PATH $out/lib/ fi '';