diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-01-13 00:12:11 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-07-20 02:43:13 -0400 |
commit | 38d5ec716adf140532889312445a0c889a281b0e (patch) | |
tree | 03ec82f3dc0ea9af31f5689c3b33f8a044567c02 | |
parent | 573603b7fdb9feb0eb8efc16ee18a015c667ab1b (diff) |
build-support/rust/lib: make arch and os functions respect target JSON
(cherry picked from commit 39811b1da9fb1c97c65ff09dd27dc3a68e6d4e65) (cherry picked from commit b49c1ce29f34a503a9e11038a156729ad7bf1fde)
-rw-r--r-- | pkgs/build-support/rust/lib/default.nix | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix index 24adcf2cb4e20..34aaa8c516a99 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; } |