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