about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers')
-rw-r--r--nixpkgs/pkgs/development/compilers/rust/default.nix15
1 files changed, 13 insertions, 2 deletions
diff --git a/nixpkgs/pkgs/development/compilers/rust/default.nix b/nixpkgs/pkgs/development/compilers/rust/default.nix
index 22d8d4e02da7..74c076c204b4 100644
--- a/nixpkgs/pkgs/development/compilers/rust/default.nix
+++ b/nixpkgs/pkgs/development/compilers/rust/default.nix
@@ -14,12 +14,23 @@
 , 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;
+
+  # Target triple. Rust has slightly different naming conventions than we use.
   toRustTarget = platform: with platform.parsed; let
-    cpu_ = {
+    cpu_ = platform.rustc.arch or {
       "armv7a" = "armv7";
       "armv7l" = "armv7";
       "armv6l" = "arm";
-    }.${cpu.name} or platform.rustc.arch or cpu.name;
+    }.${cpu.name} or cpu.name;
   in platform.rustc.config
     or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";