mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
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.
87 lines
2.1 KiB
Nix
87 lines
2.1 KiB
Nix
{
|
|
lib,
|
|
buildPackages,
|
|
callPackages,
|
|
cargo-auditable,
|
|
config,
|
|
stdenv,
|
|
runCommand,
|
|
generateSplicesForMkScope,
|
|
makeScopeWithSplicing',
|
|
}@prev:
|
|
|
|
{
|
|
rustc,
|
|
cargo,
|
|
cargo-auditable ? prev.cargo-auditable,
|
|
stdenv ? prev.stdenv,
|
|
...
|
|
}:
|
|
|
|
(makeScopeWithSplicing' {
|
|
otherSplices = generateSplicesForMkScope "rustPlatform";
|
|
f =
|
|
self:
|
|
let
|
|
inherit (self) callPackage;
|
|
in
|
|
{
|
|
fetchCargoVendor = buildPackages.callPackage ../../../build-support/rust/fetch-cargo-vendor.nix {
|
|
inherit cargo;
|
|
};
|
|
|
|
buildRustPackage = callPackage ../../../build-support/rust/build-rust-package {
|
|
inherit
|
|
stdenv
|
|
rustc
|
|
cargo
|
|
cargo-auditable
|
|
;
|
|
};
|
|
|
|
importCargoLock = buildPackages.callPackage ../../../build-support/rust/import-cargo-lock.nix {
|
|
inherit cargo;
|
|
};
|
|
|
|
rustcSrc = callPackage ./rust-src.nix {
|
|
inherit runCommand rustc;
|
|
};
|
|
|
|
rustLibSrc = callPackage ./rust-lib-src.nix {
|
|
inherit runCommand rustc;
|
|
};
|
|
|
|
# Useful when rebuilding std
|
|
# e.g. when building wasm with wasm-pack
|
|
rustVendorSrc = callPackage ./rust-vendor-src.nix {
|
|
inherit runCommand rustc;
|
|
};
|
|
|
|
# Hooks
|
|
inherit
|
|
(callPackages ../../../build-support/rust/hooks {
|
|
inherit
|
|
stdenv
|
|
;
|
|
})
|
|
cargoBuildHook
|
|
cargoCheckHook
|
|
cargoInstallHook
|
|
cargoNextestHook
|
|
cargoSetupHook
|
|
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 {
|
|
# Added in 25.05.
|
|
fetchCargoTarball = throw "`rustPlatform.fetchCargoTarball` has been removed in 25.05, use `rustPlatform.fetchCargoVendor` instead";
|
|
}
|