at 22.05-pre 89 lines 3.6 kB view raw
1{ rustcVersion 2, rustcSha256 3, enableRustcDev ? true 4, bootstrapVersion 5, bootstrapHashes 6, selectRustPackage 7, rustcPatches ? [] 8, llvmBootstrapForDarwin 9, llvmShared 10, llvmSharedForBuild 11, llvmSharedForHost 12, llvmSharedForTarget 13, llvmPackagesForBuild # Exposed through rustc for LTO in Firefox 14}: 15{ stdenv, lib 16, buildPackages 17, newScope, callPackage 18, CoreFoundation, Security, SystemConfiguration 19, pkgsBuildTarget, 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; }; 26in 27{ 28 lib = lib'; 29 30 # Backwards compat before `lib` was factored out. 31 inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec; 32 33 # This just contains tools for now. But it would conceivably contain 34 # libraries too, say if we picked some default/recommended versions from 35 # `cratesIO` to build by Hydra and/or try to prefer/bias in Cargo.lock for 36 # all vendored Carnix-generated nix. 37 # 38 # In the end game, rustc, the rust standard library (`core`, `std`, etc.), 39 # and cargo would themselves be built with `buildRustCreate` like 40 # everything else. Tools and `build.rs` and procedural macro dependencies 41 # would be taken from `buildRustPackages` (and `bootstrapRustPackages` for 42 # anything provided prebuilt or their build-time dependencies to break 43 # cycles / purify builds). In this way, nixpkgs would be in control of all 44 # bootstrapping. 45 packages = { 46 prebuilt = callPackage ./bootstrap.nix { 47 version = bootstrapVersion; 48 hashes = bootstrapHashes; 49 }; 50 stable = lib.makeScope newScope (self: let 51 # Like `buildRustPackages`, but may also contain prebuilt binaries to 52 # break cycle. Just like `bootstrapTools` for nixpkgs as a whole, 53 # nothing in the final package set should refer to this. 54 bootstrapRustPackages = self.buildRustPackages.overrideScope' (_: _: 55 lib.optionalAttrs (stdenv.buildPlatform == stdenv.hostPlatform) 56 (selectRustPackage buildPackages).packages.prebuilt); 57 bootRustPlatform = makeRustPlatform bootstrapRustPackages; 58 in { 59 # Packages suitable for build-time, e.g. `build.rs`-type stuff. 60 buildRustPackages = (selectRustPackage buildPackages).packages.stable; 61 # Analogous to stdenv 62 rustPlatform = makeRustPlatform self.buildRustPackages; 63 rustc = self.callPackage ./rustc.nix ({ 64 version = rustcVersion; 65 sha256 = rustcSha256; 66 inherit enableRustcDev; 67 inherit llvmShared llvmSharedForBuild llvmSharedForHost llvmSharedForTarget llvmPackagesForBuild; 68 69 patches = rustcPatches; 70 71 # Use boot package set to break cycle 72 rustPlatform = bootRustPlatform; 73 } // lib.optionalAttrs (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) { 74 stdenv = llvmBootstrapForDarwin.stdenv; 75 pkgsBuildBuild = pkgsBuildBuild // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; }; 76 pkgsBuildHost = pkgsBuildBuild // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; }; 77 pkgsBuildTarget = pkgsBuildTarget // { targetPackages.stdenv = llvmBootstrapForDarwin.stdenv; }; 78 }); 79 rustfmt = self.callPackage ./rustfmt.nix { inherit Security; }; 80 cargo = self.callPackage ./cargo.nix { 81 # Use boot package set to break cycle 82 rustPlatform = bootRustPlatform; 83 inherit CoreFoundation Security; 84 }; 85 clippy = self.callPackage ./clippy.nix { inherit Security; }; 86 rls = self.callPackage ./rls { inherit CoreFoundation Security SystemConfiguration; }; 87 }); 88 }; 89}