nixpkgs/pkgs/development/compilers/rust/default.nix

63 lines
2.3 KiB
Nix
Raw Normal View History

2018-11-21 01:47:45 +00:00
{ stdenv, lib, overrideCC
, buildPackages
, newScope, callPackage
, CoreFoundation, Security
2018-11-21 01:47:45 +00:00
}: rec {
makeRustPlatform = { rustc, cargo, ... }: {
rust = {
inherit rustc cargo;
};
2018-11-21 01:47:45 +00:00
buildRustPackage = callPackage ../../../build-support/rust {
inherit rustc cargo;
2018-11-21 01:47:45 +00:00
fetchcargo = buildPackages.callPackage ../../../build-support/rust/fetchcargo.nix {
inherit cargo;
};
};
2018-07-09 10:35:01 +00:00
2018-11-21 01:47:45 +00:00
rustcSrc = callPackage ./rust-src.nix {
inherit rustc;
};
};
2018-11-21 01:47:45 +00:00
# This just contains tools for now. But it would conceivably contain
# libraries too, say if we picked some default/recommended versions from
# `cratesIO` to build by Hydra and/or try to prefer/bias in Cargo.lock for
# all vendored Carnix-generated nix.
#
# In the end game, rustc, the rust standard library (`core`, `std`, etc.),
# and cargo would themselves be built with `buildRustCreate` like
# everything else. Tools and `build.rs` and procedural macro dependencies
# would be taken from `buildRustPackages` (and `bootstrapRustPackages` for
# anything provided prebuilt or their build-time dependencies to break
# cycles / purify builds). In this way, nixpkgs would be in control of all
# bootstrapping.
packages = {
prebuilt = callPackage ./bootstrap.nix {};
stable = lib.makeScope newScope (self: let
# Like `buildRustPackages`, but may also contain prebuilt binaries to
# break cycle. Just like `bootstrapTools` for nixpkgs as a whole,
# nothing in the final package set should refer to this.
bootstrapRustPackages = self.buildRustPackages.overrideScope' (_: _:
lib.optionalAttrs (stdenv.buildPlatform == stdenv.hostPlatform)
buildPackages.rust.packages.prebuilt);
bootRustPlatform = makeRustPlatform bootstrapRustPackages;
in {
# Packages suitable for build-time, e.g. `build.rs`-type stuff.
buildRustPackages = buildPackages.rust.packages.stable;
# Analogous to stdenv
rustPlatform = makeRustPlatform self.buildRustPackages;
2019-03-12 01:19:48 +00:00
rustc = self.callPackage ./rustc.nix {
2018-11-21 01:47:45 +00:00
# Use boot package set to break cycle
rustPlatform = bootRustPlatform;
2019-03-12 01:19:48 +00:00
};
cargo = self.callPackage ./cargo.nix {
2018-11-21 01:47:45 +00:00
# Use boot package set to break cycle
rustPlatform = bootRustPlatform;
inherit CoreFoundation Security;
2019-03-12 01:19:48 +00:00
};
2018-11-21 01:47:45 +00:00
});
};
}