cargo: remove runtime references to cargo-bootstrap (#510169)

This commit is contained in:
Jonas Chevalier 2026-07-01 06:51:44 +00:00 committed by GitHub
commit f23e8ad032
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 8 deletions

View file

@ -80,9 +80,9 @@ rustPlatform.buildRustPackage.override
if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
''
installShellCompletion --cmd cargo \
--bash <(CARGO_COMPLETE=bash cargo) \
--fish <(CARGO_COMPLETE=fish cargo) \
--zsh <(CARGO_COMPLETE=zsh cargo)
--bash <(CARGO_COMPLETE=bash $out/bin/cargo) \
--fish <(CARGO_COMPLETE=fish $out/bin/cargo) \
--zsh <(CARGO_COMPLETE=zsh $out/bin/cargo)
''
else
''
@ -109,6 +109,13 @@ rustPlatform.buildRustPackage.override
runHook postInstallCheck
'';
# Make sure our build rustc/cargo never make it into our runtime closure
disallowedReferences = [
rustPlatform.rust.cargo
rustPlatform.rust.rustc
rustPlatform.rust.rustc.unwrapped
];
meta = {
homepage = "https://crates.io";
description = "Downloads your Rust project's dependencies and builds your project";

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";
}

View file

@ -448,6 +448,12 @@ stdenv.mkDerivation (finalAttrs: {
requiredSystemFeatures = [ "big-parallel" ];
# Make sure our bootstrap packages don't end up in our runtime closure
disallowedReferences = [
cargo
rustc
];
passthru = {
llvm = llvmShared;
inherit llvmPackages;