From db89c8707edcffefcd8e738459d511543a339ff5 Mon Sep 17 00:00:00 2001 From: Christian Albrecht Date: Thu, 27 Jul 2023 23:27:55 +0200 Subject: [PATCH] overlays.rust: fix fromManifest postBuild realpath for rust-src build When building rust-src like in ``` nix build --impure -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz --argstr PWD $PWD --expr '{ PWD }:(import { overlays = (builtins.getFlake PWD).overlays.rust ];}).latest.rustChannels.stable.rust-src' -L --out-link rust-src-stable ``` after fixing the previous error the build failed since commit https://github.com/mozilla/nixpkgs-mozilla/commit/f6fe8508b0910b84b74c0e0bfa0ff8593e77d470 with an error like ``` realpath: missing operand ``` because, bash shopt nullglob is enabled during build which leads to a non-existing glob matching pattern to be a null string and therefore the check with `ls $out/lib/librustc_driver-*.so` lists the whole directory and succeeds. ``` bash -c 'shopt -s nullglob; if ls $PWD/rust-o*.nixxxxxxxxxxx &> /dev/null ; then echo yes ; else echo no ; fi' yes ``` This commit changes the check to compare the null string resulting from glob pattern match with nullglob enabled against another null string. --- rust-overlay.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-overlay.nix b/rust-overlay.nix index 5f6ffe3..31fa430 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -297,7 +297,7 @@ let # Here we copy the librustc_driver-*.so to our derivation. # The SYSROOT is determined based on the path of this library. - if ls $out/lib/librustc_driver-*.so &> /dev/null; then + if test "" != $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/