2019-11-08 13:04:53 +01:00
|
|
|
{ rustcVersion
|
|
|
|
, rustcSha256
|
|
|
|
, bootstrapVersion
|
|
|
|
, bootstrapHashes
|
|
|
|
, selectRustPackage
|
|
|
|
}:
|
2019-06-16 21:59:06 +02:00
|
|
|
{ stdenv, lib
|
2018-11-21 02:47:45 +01:00
|
|
|
, buildPackages
|
|
|
|
, newScope, callPackage
|
2018-10-26 17:06:56 +02:00
|
|
|
, CoreFoundation, Security
|
2019-04-23 15:25:12 +02:00
|
|
|
, llvmPackages_5
|
2019-06-16 21:59:06 +02:00
|
|
|
, pkgsBuildTarget, pkgsBuildBuild
|
2018-11-21 02:47:45 +01:00
|
|
|
}: rec {
|
|
|
|
makeRustPlatform = { rustc, cargo, ... }: {
|
|
|
|
rust = {
|
|
|
|
inherit rustc cargo;
|
|
|
|
};
|
2016-06-14 12:49:48 +02:00
|
|
|
|
2018-11-21 02:47:45 +01:00
|
|
|
buildRustPackage = callPackage ../../../build-support/rust {
|
|
|
|
inherit rustc cargo;
|
2017-05-30 15:48:06 +02:00
|
|
|
|
2018-11-21 02:47:45 +01:00
|
|
|
fetchcargo = buildPackages.callPackage ../../../build-support/rust/fetchcargo.nix {
|
|
|
|
inherit cargo;
|
|
|
|
};
|
|
|
|
};
|
2018-07-09 12:35:01 +02:00
|
|
|
|
2018-11-21 02:47:45 +01:00
|
|
|
rustcSrc = callPackage ./rust-src.nix {
|
|
|
|
inherit rustc;
|
|
|
|
};
|
2016-06-14 12:49:48 +02:00
|
|
|
};
|
|
|
|
|
2018-11-21 02:47:45 +01: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 = {
|
2019-11-08 13:04:53 +01:00
|
|
|
prebuilt = callPackage ./bootstrap.nix {
|
|
|
|
version = bootstrapVersion;
|
|
|
|
hashes = bootstrapHashes;
|
|
|
|
};
|
2018-11-21 02:47:45 +01:00
|
|
|
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)
|
2019-11-08 13:04:53 +01:00
|
|
|
(selectRustPackage buildPackages).packages.prebuilt);
|
2018-11-21 02:47:45 +01:00
|
|
|
bootRustPlatform = makeRustPlatform bootstrapRustPackages;
|
|
|
|
in {
|
|
|
|
# Packages suitable for build-time, e.g. `build.rs`-type stuff.
|
2019-11-08 13:04:53 +01:00
|
|
|
buildRustPackages = (selectRustPackage buildPackages).packages.stable;
|
2018-11-21 02:47:45 +01:00
|
|
|
# Analogous to stdenv
|
|
|
|
rustPlatform = makeRustPlatform self.buildRustPackages;
|
2019-04-23 15:25:12 +02:00
|
|
|
rustc = self.callPackage ./rustc.nix ({
|
2019-11-08 13:04:53 +01:00
|
|
|
version = rustcVersion;
|
|
|
|
sha256 = rustcSha256;
|
|
|
|
|
2018-11-21 02:47:45 +01:00
|
|
|
# Use boot package set to break cycle
|
|
|
|
rustPlatform = bootRustPlatform;
|
2019-04-23 15:25:12 +02:00
|
|
|
} // lib.optionalAttrs (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) {
|
|
|
|
stdenv = llvmPackages_5.stdenv;
|
|
|
|
pkgsBuildBuild = pkgsBuildBuild // { targetPackages.stdenv = llvmPackages_5.stdenv; };
|
|
|
|
pkgsBuildHost = pkgsBuildBuild // { targetPackages.stdenv = llvmPackages_5.stdenv; };
|
|
|
|
pkgsBuildTarget = pkgsBuildTarget // { targetPackages.stdenv = llvmPackages_5.stdenv; };
|
|
|
|
});
|
2019-08-16 12:26:51 +02:00
|
|
|
rustfmt = self.callPackage ./rustfmt.nix { inherit Security; };
|
2019-03-12 02:19:48 +01:00
|
|
|
cargo = self.callPackage ./cargo.nix {
|
2018-11-21 02:47:45 +01:00
|
|
|
# Use boot package set to break cycle
|
|
|
|
rustPlatform = bootRustPlatform;
|
|
|
|
inherit CoreFoundation Security;
|
2019-03-12 02:19:48 +01:00
|
|
|
};
|
2019-08-15 16:13:01 +02:00
|
|
|
clippy = self.callPackage ./clippy.nix { inherit Security; };
|
2019-08-16 19:03:38 +02:00
|
|
|
rls = self.callPackage ./rls { inherit CoreFoundation Security; };
|
2018-11-21 02:47:45 +01:00
|
|
|
});
|
2016-06-14 12:49:48 +02:00
|
|
|
};
|
|
|
|
}
|