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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3.5 KiB
Nix
Raw Normal View History

{ rustcVersion
, rustcSha256
, enableRustcDev ? true
, bootstrapVersion
, bootstrapHashes
, selectRustPackage
, rustcPatches ? []
, llvmBootstrapForDarwin
, llvmShared
, llvmSharedForBuild
, llvmSharedForHost
, llvmSharedForTarget
, llvmPackages # Exposed through rustc for LTO in Firefox
}:
{ stdenv, lib
2018-11-21 01:47:45 +00:00
, buildPackages
, newScope, callPackage
, CoreFoundation, Security, SystemConfiguration
, pkgsBuildTarget, pkgsBuildBuild
, makeRustPlatform
}:
let
# Use `import` to make sure no packages sneak in here.
lib' = import ../../../build-support/rust/lib { inherit lib; };
in
{
lib = lib';
# Backwards compat before `lib` was factored out.
2022-10-07 14:35:29 +00:00
inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec IsNoStdTarget;
2018-11-21 01:47:45 +00:00
# This just contains tools for now. But it would conceivably contain
2022-10-15 18:34:28 +00:00
# libraries too, say if we picked some default/recommended versions to build
# by Hydra.
2018-11-21 01:47:45 +00:00
#
# 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 {
version = bootstrapVersion;
hashes = bootstrapHashes;
};
2018-11-21 01:47:45 +00: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)
(selectRustPackage buildPackages).packages.prebuilt);
2018-11-21 01:47:45 +00:00
bootRustPlatform = makeRustPlatform bootstrapRustPackages;
in {
# Packages suitable for build-time, e.g. `build.rs`-type stuff.
buildRustPackages = (selectRustPackage buildPackages).packages.stable;
2018-11-21 01:47:45 +00:00
# Analogous to stdenv
rustPlatform = makeRustPlatform self.buildRustPackages;
2019-04-23 13:25:12 +00:00
rustc = self.callPackage ./rustc.nix ({
version = rustcVersion;
sha256 = rustcSha256;
inherit enableRustcDev;
inherit llvmShared llvmSharedForBuild llvmSharedForHost llvmSharedForTarget llvmPackages;
patches = rustcPatches;
2018-11-21 01:47:45 +00:00
# Use boot package set to break cycle
rustPlatform = bootRustPlatform;
2019-04-23 13:25:12 +00:00
} // lib.optionalAttrs (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) {
stdenv = llvmBootstrapForDarwin.stdenv;
pkgsBuildBuild = pkgsBuildBuild // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; };
pkgsBuildHost = pkgsBuildBuild // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; };
pkgsBuildTarget = pkgsBuildTarget // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; };
2019-04-23 13:25:12 +00:00
});
rustfmt = self.callPackage ./rustfmt.nix { inherit Security; };
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
};
cargo-auditable = self.callPackage ./cargo-auditable.nix { };
cargo-auditable-cargo-wrapper = self.callPackage ./cargo-auditable-cargo-wrapper.nix { };
clippy = self.callPackage ./clippy.nix { inherit Security; };
2018-11-21 01:47:45 +00:00
});
};
}