From 39811b1da9fb1c97c65ff09dd27dc3a68e6d4e65 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 13 Jan 2022 00:12:11 +0000 Subject: [PATCH] build-support/rust/lib: make arch and os functions respect target JSON --- pkgs/build-support/rust/lib/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix index 24adcf2cb4e2..34aaa8c516a9 100644 --- a/pkgs/build-support/rust/lib/default.nix +++ b/pkgs/build-support/rust/lib/default.nix @@ -3,12 +3,14 @@ rec { # https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch toTargetArch = platform: - if platform.isAarch32 then "arm" + /**/ if platform ? rustc.platform then platform.rustc.platform.arch + else 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" + /**/ if platform ? rustc.platform then platform.rustc.platform.os or "none" + else if platform.isDarwin then "macos" else platform.parsed.kernel.name; # Returns the name of the rust target, even if it is custom. Adjustments are @@ -31,7 +33,7 @@ rec { # 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 + if platform ? rustc.platform then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform) else toRustTarget platform; }