rustPlatform.buildRustPackage: Pass env.RUSTFLAGS only when specified or needed to fix builds (#464707)

This commit is contained in:
Alyssa Ross
2025-11-30 14:56:38 +00:00
committed by GitHub
@@ -89,17 +89,20 @@ lib.extendMkDerivation {
"buildRustPackage: `useFetchCargoVendor` is nonoptional and enabled by default as of 25.05, remove it"
true;
{
env = {
PKG_CONFIG_ALLOW_CROSS = if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0;
RUST_LOG = logLevel;
RUSTFLAGS =
lib.optionalString (
stdenv.hostPlatform.isDarwin && buildType == "debug"
) "-C split-debuginfo=packed "
# Workaround the existing RUSTFLAGS specified as a list.
+ interpolateString (args.RUSTFLAGS or "");
}
// args.env or { };
env =
let
isDarwinDebug = stdenv.hostPlatform.isDarwin && buildType == "debug";
in
{
PKG_CONFIG_ALLOW_CROSS = if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0;
RUST_LOG = logLevel;
# Prevent shadowing *_RUSTFLAGS environment variables
${if args ? RUSTFLAGS || isDarwinDebug then "RUSTFLAGS" else null} =
lib.optionalString isDarwinDebug "-C split-debuginfo=packed "
# Workaround the existing RUSTFLAGS specified as a list.
+ interpolateString (args.RUSTFLAGS or "");
}
// args.env or { };
cargoDeps =
if cargoVendorDir != null then