diff --git a/pkgs/development/compilers/rust/cargo.nix b/pkgs/development/compilers/rust/cargo.nix index a86e4a3d186d..3fb4f948a223 100644 --- a/pkgs/development/compilers/rust/cargo.nix +++ b/pkgs/development/compilers/rust/cargo.nix @@ -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"; diff --git a/pkgs/development/compilers/rust/make-rust-platform.nix b/pkgs/development/compilers/rust/make-rust-platform.nix index 1f69bb92e213..254ae918bbf6 100644 --- a/pkgs/development/compilers/rust/make-rust-platform.nix +++ b/pkgs/development/compilers/rust/make-rust-platform.nix @@ -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"; } diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index cf86b5412571..f5c09e0740ba 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -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;