From fe3ffda7efb90202e5d4b74f1ba284635174327d Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Sat, 24 Feb 2024 17:41:50 -0600 Subject: [PATCH] nix: fix nix-on-macOS build When the `jj-proc-macros` crate was introduced, it triggered an underlying bug in `nextest`, which is the test harness we use in the Nix build. This is upstream Nextest bug 267. The long and short of it is that `rustc` fails to find needed libraries whenever the proc macros are loaded. This can easily be worked around however, by setting `DYLD_FALLBACK_LIBRARY_PATH` to an appropriate value in the devShell and in the `preCheck` phase of the main expression. Signed-off-by: Austin Seipp --- flake.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 9a1caa8ee..5a0544268 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,12 @@ libiconv ]; + # work around https://github.com/nextest-rs/nextest/issues/267 + # this needs to exist in both the devShell and preCheck phase! + darwinNextestHack = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' + export DYLD_FALLBACK_LIBRARY_PATH=$(${ourRustVersion}/bin/rustc --print sysroot)/lib + ''; + # NOTE (aseipp): on Linux, go ahead and use mold by default to improve # link times a bit; mostly useful for debug build speed, but will help # over time if we ever get more dependencies, too @@ -97,7 +103,10 @@ NIX_JJ_GIT_HASH = self.rev or ""; CARGO_INCREMENTAL = "0"; - preCheck = "export RUST_BACKTRACE=1"; + preCheck = '' + export RUST_BACKTRACE=1 + '' + darwinNextestHack; + postInstall = '' $out/bin/jj util mangen > ./jj.1 installManPage ./jj.1 @@ -181,7 +190,7 @@ export LIBSSH2_SYS_USE_PKG_CONFIG=1 '' + pkgs.lib.optionalString useMoldLinker '' export RUSTFLAGS="-C link-arg=-fuse-ld=mold" - ''; + '' + darwinNextestHack; }; })); }