about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/build-support/rust/lib/default.nix13
1 files changed, 9 insertions, 4 deletions
diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix
index 77397f9b7220c..aa5ba14c1397b 100644
--- a/pkgs/build-support/rust/lib/default.nix
+++ b/pkgs/build-support/rust/lib/default.nix
@@ -30,10 +30,17 @@ rec {
     else lib.optional platform.isUnix "unix"
       ++ lib.optional platform.isWindows "windows";
 
+  # https://doc.rust-lang.org/reference/conditional-compilation.html#target_vendor
+  toTargetVendor = platform: let
+    inherit (platform.parsed) vendor;
+  in platform.rustc.platform.vendor or {
+    "w64" = "pc";
+  }.${vendor.name} or vendor.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: let
-    inherit (platform.parsed) cpu vendor kernel abi;
+    inherit (platform.parsed) cpu kernel abi;
     cpu_ = platform.rustc.platform.arch or {
       "armv7a" = "armv7";
       "armv7l" = "armv7";
@@ -41,9 +48,7 @@ rec {
       "armv5tel" = "armv5te";
       "riscv64" = "riscv64gc";
     }.${cpu.name} or cpu.name;
-    vendor_ = platform.rustc.platform.vendor or {
-      "w64" = "pc";
-    }.${vendor.name} or vendor.name;
+    vendor_ = toTargetVendor platform;
   in platform.rustc.config
     or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";