ok/jj
1
0
Fork 0
forked from mirrors/jj

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 <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2024-02-24 17:41:50 -06:00 committed by Martin von Zweigbergk
parent 29e959d18c
commit fe3ffda7ef

View file

@ -49,6 +49,12 @@
libiconv 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 # 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 # link times a bit; mostly useful for debug build speed, but will help
# over time if we ever get more dependencies, too # over time if we ever get more dependencies, too
@ -97,7 +103,10 @@
NIX_JJ_GIT_HASH = self.rev or ""; NIX_JJ_GIT_HASH = self.rev or "";
CARGO_INCREMENTAL = "0"; CARGO_INCREMENTAL = "0";
preCheck = "export RUST_BACKTRACE=1"; preCheck = ''
export RUST_BACKTRACE=1
'' + darwinNextestHack;
postInstall = '' postInstall = ''
$out/bin/jj util mangen > ./jj.1 $out/bin/jj util mangen > ./jj.1
installManPage ./jj.1 installManPage ./jj.1
@ -181,7 +190,7 @@
export LIBSSH2_SYS_USE_PKG_CONFIG=1 export LIBSSH2_SYS_USE_PKG_CONFIG=1
'' + pkgs.lib.optionalString useMoldLinker '' '' + pkgs.lib.optionalString useMoldLinker ''
export RUSTFLAGS="-C link-arg=-fuse-ld=mold" export RUSTFLAGS="-C link-arg=-fuse-ld=mold"
''; '' + darwinNextestHack;
}; };
})); }));
} }