at 24.11-pre 106 lines 4.1 kB view raw
1{ rustcVersion 2, rustcSha256 3, enableRustcDev ? true 4, bootstrapVersion 5, bootstrapHashes 6, selectRustPackage 7, rustcPatches ? [] 8, llvmShared 9, llvmSharedForBuild 10, llvmSharedForHost 11, llvmSharedForTarget 12, llvmPackages # Exposed through rustc for LTO in Firefox 13}: 14{ stdenv, lib 15, newScope, callPackage 16, CoreFoundation, Security, SystemConfiguration 17, pkgsBuildBuild 18, pkgsBuildHost 19, pkgsBuildTarget 20, pkgsTargetTarget 21, makeRustPlatform 22, wrapRustcWith 23}: 24 25let 26 # Use `import` to make sure no packages sneak in here. 27 lib' = import ../../../build-support/rust/lib { 28 inherit lib stdenv pkgsBuildHost pkgsBuildTarget pkgsTargetTarget; 29 }; 30 # Allow faster cross compiler generation by reusing Build artifacts 31 fastCross = (stdenv.buildPlatform == stdenv.hostPlatform) && (stdenv.hostPlatform != stdenv.targetPlatform); 32in 33{ 34 lib = lib'; 35 36 # Backwards compat before `lib` was factored out. 37 inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec IsNoStdTarget toRustTargetForUseInEnvVars envVars; 38 39 # This just contains tools for now. But it would conceivably contain 40 # libraries too, say if we picked some default/recommended versions to build 41 # by Hydra. 42 # 43 # In the end game, rustc, the rust standard library (`core`, `std`, etc.), 44 # and cargo would themselves be built with `buildRustCreate` like 45 # everything else. Tools and `build.rs` and procedural macro dependencies 46 # would be taken from `buildRustPackages` (and `bootstrapRustPackages` for 47 # anything provided prebuilt or their build-time dependencies to break 48 # cycles / purify builds). In this way, nixpkgs would be in control of all 49 # bootstrapping. 50 packages = { 51 prebuilt = callPackage ./bootstrap.nix { 52 version = bootstrapVersion; 53 hashes = bootstrapHashes; 54 }; 55 stable = lib.makeScope newScope (self: let 56 # Like `buildRustPackages`, but may also contain prebuilt binaries to 57 # break cycle. Just like `bootstrapTools` for nixpkgs as a whole, 58 # nothing in the final package set should refer to this. 59 bootstrapRustPackages = if fastCross 60 then pkgsBuildBuild.rustPackages 61 else 62 self.buildRustPackages.overrideScope (_: _: 63 lib.optionalAttrs (stdenv.buildPlatform == stdenv.hostPlatform) 64 (selectRustPackage pkgsBuildHost).packages.prebuilt); 65 bootRustPlatform = makeRustPlatform bootstrapRustPackages; 66 in { 67 # Packages suitable for build-time, e.g. `build.rs`-type stuff. 68 buildRustPackages = (selectRustPackage pkgsBuildHost).packages.stable // { __attrsFailEvaluation = true; }; 69 # Analogous to stdenv 70 rustPlatform = makeRustPlatform self.buildRustPackages; 71 rustc-unwrapped = self.callPackage ./rustc.nix ({ 72 version = rustcVersion; 73 sha256 = rustcSha256; 74 inherit enableRustcDev; 75 inherit llvmShared llvmSharedForBuild llvmSharedForHost llvmSharedForTarget llvmPackages fastCross; 76 77 patches = rustcPatches; 78 79 # Use boot package set to break cycle 80 inherit (bootstrapRustPackages) cargo rustc rustfmt; 81 }); 82 rustc = wrapRustcWith { 83 inherit (self) rustc-unwrapped; 84 sysroot = if fastCross then self.rustc-unwrapped else null; 85 }; 86 rustfmt = self.callPackage ./rustfmt.nix { 87 inherit Security; 88 inherit (self.buildRustPackages) rustc; 89 }; 90 cargo = if (!fastCross) then self.callPackage ./cargo.nix { 91 # Use boot package set to break cycle 92 rustPlatform = bootRustPlatform; 93 inherit CoreFoundation Security; 94 } else self.callPackage ./cargo_cross.nix {}; 95 cargo-auditable = self.callPackage ./cargo-auditable.nix { }; 96 cargo-auditable-cargo-wrapper = self.callPackage ./cargo-auditable-cargo-wrapper.nix { }; 97 clippy = self.callPackage ./clippy.nix { 98 # We want to use self, not buildRustPackages, so that 99 # buildPackages.clippy uses the cross compiler and supports 100 # linting for the target platform. 101 rustPlatform = makeRustPlatform self; 102 inherit Security; 103 }; 104 }); 105 }; 106}