rustPlatform.rust: undeprecate

These attributes were deprecated in #230951 because they confused things
with splicing, e.g. passing `rustPlatform.rust.rustc` to
`nativeBuildInputs` would get the wrong derivation when cross-compiling.
This was a consequence of the fact that they come from the buildPackages
set. But we still want to expose these packages as otherwise Rust
packages have no way to reference the rustc and cargo that build them,
which means they can't e.g. use `disallowedReferences` to ensure they
don't end up in the runtime closure.

Just as `stdenv.cc` itself isn't spliced, we can solve this problem by
unsplicing the packages.
This commit is contained in:
Lily Ballard 2026-04-15 21:28:26 -07:00
commit 8eb3c82575

View file

@ -72,14 +72,16 @@
maturinBuildHook
bindgenHook
;
# Let packages reference the build derivations, e.g. for disallowedReferences.
# Get rid of the splicing though, so `nativeBuildInputs = [ rustPlatform.rust.rustc ]` works.
rust = {
rustc = rustc.__spliced.hostTarget or rustc;
cargo = cargo.__spliced.hostTarget or cargo;
};
};
})
// lib.optionalAttrs config.allowAliases {
rust = {
rustc = lib.warn "rustPlatform.rust.rustc is deprecated. Use rustc instead." rustc;
cargo = lib.warn "rustPlatform.rust.cargo is deprecated. Use cargo instead." cargo;
};
# Added in 25.05.
fetchCargoTarball = throw "`rustPlatform.fetchCargoTarball` has been removed in 25.05, use `rustPlatform.fetchCargoVendor` instead";
}