diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-11-07 20:51:04 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-11-07 20:51:04 +0000 |
commit | 4f81865aa1462945be72eee45b27dcc0d1b3845b (patch) | |
tree | 9dd7e51a1d4374a5435554f1f3be2669f5ab002c /pkgs/development/compilers/rust | |
parent | 14f1b9f2ac94f276a31a3e47315e34a2ce1652a7 (diff) | |
parent | 17f230461a1010cdb0d0bb92594546429c69de47 (diff) |
Merge remote-tracking branch 'upstream/master' into staging-next
Diffstat (limited to 'pkgs/development/compilers/rust')
-rw-r--r-- | pkgs/development/compilers/rust/default.nix | 40 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/make-rust-platform.nix | 4 |
2 files changed, 11 insertions, 33 deletions
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index 59420477119c6..6dfc8a49063f9 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -18,39 +18,17 @@ , CoreFoundation, Security, SystemConfiguration , pkgsBuildTarget, pkgsBuildBuild , makeRustPlatform -}: rec { - # https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch - toTargetArch = platform: - if platform.isAarch32 then "arm" - else platform.parsed.cpu.name; - - # https://doc.rust-lang.org/reference/conditional-compilation.html#target_os - toTargetOs = platform: - if platform.isDarwin then "macos" - else platform.parsed.kernel.name; +}: - # Returns the name of the rust target, even if it is custom. Adjustments are - # because rust has slightly different naming conventions than we do. - toRustTarget = platform: with platform.parsed; let - cpu_ = platform.rustc.platform.arch or { - "armv7a" = "armv7"; - "armv7l" = "armv7"; - "armv6l" = "arm"; - "armv5tel" = "armv5te"; - "riscv64" = "riscv64gc"; - }.${cpu.name} or cpu.name; - vendor_ = platform.rustc.platform.vendor or { - "w64" = "pc"; - }.${vendor.name} or vendor.name; - in platform.rustc.config - or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"; +let + # Use `import` to make sure no packages sneak in here. + lib' = import ../../../build-support/rust/lib { inherit lib; }; +in +{ + lib = lib'; - # Returns the name of the rust target if it is standard, or the json file - # containing the custom target spec. - toRustTargetSpec = platform: - if (platform.rustc or {}) ? platform - then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform) - else toRustTarget platform; + # Backwards compat before `lib` was factored out. + inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec; # This just contains tools for now. But it would conceivably contain # libraries too, say if we picked some default/recommended versions from diff --git a/pkgs/development/compilers/rust/make-rust-platform.nix b/pkgs/development/compilers/rust/make-rust-platform.nix index 33d826eef5077..f479b052019e1 100644 --- a/pkgs/development/compilers/rust/make-rust-platform.nix +++ b/pkgs/development/compilers/rust/make-rust-platform.nix @@ -7,12 +7,12 @@ rec { inherit rustc cargo; }; - fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetchCargoTarball.nix { + fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetch-cargo-tarball { git = buildPackages.gitMinimal; inherit cargo; }; - buildRustPackage = callPackage ../../../build-support/rust { + buildRustPackage = callPackage ../../../build-support/rust/build-rust-package { git = buildPackages.gitMinimal; inherit stdenv cargoBuildHook cargoCheckHook cargoInstallHook cargoSetupHook fetchCargoTarball importCargoLock rustc; |