From e212e10deee96878236c12a565d99abcc18d2fcb Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Fri, 14 Jul 2023 06:34:36 -0500 Subject: [PATCH] feat(nix): use mold by default for linking inside 'nix develop' Summary: Pure QOL improvement, not that this was too awful as it stood. But this ultimately makes all builds faster, effectively for free; on my Linux machine, debug link time for jj-cli goes from 3s to 1s. Signed-off-by: Austin Seipp Change-Id: I5a0d516363635710733e8bee8f208050 --- flake.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index f35d31ab4..1b338a47d 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ rust-overlay.overlays.default ]; }; + filterSrc = src: regexes: pkgs.lib.cleanSourceWith { inherit src; @@ -33,6 +34,11 @@ in pkgs.lib.all (re: builtins.match re relPath == null) regexes; }; + + # 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 + useMoldLinker = pkgs.stdenv.isLinux; in { packages = { @@ -118,12 +124,16 @@ cargo-insta cargo-nextest cargo-watch - ]; + + # Extra, more specific tools follow + ] ++ pkgs.lib.optionals useMoldLinker [ mold ]; shellHook = '' export RUST_BACKTRACE=1 export ZSTD_SYS_USE_PKG_CONFIG=1 export LIBSSH2_SYS_USE_PKG_CONFIG=1 + '' + pkgs.lib.optionalString useMoldLinker '' + export RUSTFLAGS="-C link-arg=-fuse-ld=mold $RUSTFLAGS" ''; }; }));