summary refs log tree commit diff
path: root/pkgs/development/compilers/rust/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/rust/default.nix')
-rw-r--r--pkgs/development/compilers/rust/default.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix
index 0fbe5b8c0ed..fc1af5a3f94 100644
--- a/pkgs/development/compilers/rust/default.nix
+++ b/pkgs/development/compilers/rust/default.nix
@@ -24,7 +24,8 @@
     if platform.isDarwin then "macos"
     else platform.parsed.kernel.name;
 
-  # Target triple. Rust has slightly different naming conventions than we use.
+  # 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.arch or {
       "armv7a" = "armv7";
@@ -34,6 +35,13 @@
   in platform.rustc.config
     or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
 
+  # 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.arch or {}) ? custom
+    then builtins.toFile (platform.rustc.config + ".json") (builtins.toJSON platform.rustc.arch.custom)
+    else toRustTarget platform;
+
   # This just contains tools for now. But it would conceivably contain
   # libraries too, say if we picked some default/recommended versions from
   # `cratesIO` to build by Hydra and/or try to prefer/bias in Cargo.lock for