Skip to content

Commit

Permalink
nix: fix nix-on-macOS build
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thoughtpolice committed Feb 24, 2024
1 parent cd53a63 commit 84b6ce5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -181,7 +190,7 @@
export LIBSSH2_SYS_USE_PKG_CONFIG=1
'' + pkgs.lib.optionalString useMoldLinker ''
export RUSTFLAGS="-C link-arg=-fuse-ld=mold"
'';
'' + darwinNextestHack;
};
}));
}

0 comments on commit 84b6ce5

Please sign in to comment.