git: fix rust cross-compilation

... while trying to avoid triggering rebuilds in the non-cross case.

It feels like there is surely a better way to do this?
This commit is contained in:
Nathaniel Wesley Filardo
2026-02-26 05:05:25 +00:00
parent 360b78b5de
commit ce7d77de51

View File

@@ -166,6 +166,11 @@ stdenv.mkDerivation (finalAttrs: {
substituteInPlace "$x" \
--subst-var-by ssh "${openssh}/bin/ssh"
done
''
+ lib.optionalString (rustSupport && (stdenv.buildPlatform != stdenv.hostPlatform)) ''
substituteInPlace Makefile \
--replace-fail "RUST_TARGET_DIR = target/" \
"RUST_TARGET_DIR = target/${stdenv.hostPlatform.rust.rustcTargetSpec}/"
'';
nativeBuildInputs = [
@@ -207,10 +212,16 @@ stdenv.mkDerivation (finalAttrs: {
libsecret
];
# required to support pthread_cancel()
env.NIX_LDFLAGS =
lib.optionalString (stdenv.cc.isGNU && stdenv.hostPlatform.libc == "glibc") "-lgcc_s"
+ lib.optionalString (stdenv.hostPlatform.isFreeBSD) "-lthr";
env = {
# required to support pthread_cancel()
NIX_LDFLAGS =
lib.optionalString (stdenv.cc.isGNU && stdenv.hostPlatform.libc == "glibc") "-lgcc_s"
+ lib.optionalString (stdenv.hostPlatform.isFreeBSD) "-lthr";
}
// lib.attrsets.optionalAttrs (rustSupport && (stdenv.buildPlatform != stdenv.hostPlatform)) {
# Rust cross-compilation
CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
};
configureFlags = [
"ac_cv_prog_CURL_CONFIG=${lib.getDev curl}/bin/curl-config"