1{ lib, platform }:
2let
3 self = {
4 os =
5 if platform.isLinux then
6 "linux"
7 else if platform.isDarwin then
8 "macos"
9 else if platform.isWindows then
10 "windows"
11 else
12 throw "Unsupported OS \"${platform.parsed.kernel.name}\"";
13
14 alt-os = if platform.isDarwin then "mac" else self.os;
15
16 arch =
17 if platform.isx86_64 then
18 "amd64"
19 else if platform.isx86 && platform.is32bit then
20 "386"
21 else if platform.isAarch64 then
22 "arm64"
23 else if platform.isMips && platform.parsed.cpu.significantByte == "littleEndian" then
24 "mipsle"
25 else if platform.isMips64 then
26 "mips64${lib.optionalString (platform.parsed.cpu.significantByte == "littleEndian") "le"}"
27 else if platform.isPower64 then
28 "ppc64${lib.optionalString (platform.parsed.cpu.significantByte == "littleEndian") "le"}"
29 else if platform.isS390x then
30 "s390x"
31 else if platform.isRiscV64 then
32 "riscv64"
33 else
34 throw "Unsupported CPU \"${platform.parsed.cpu.name}\"";
35
36 alt-arch =
37 if platform.isx86_64 then
38 "x64"
39 else if platform.isAarch64 then
40 "arm64"
41 else
42 platform.parsed.cpu.name;
43
44 platform = "${self.os}-${self.arch}";
45 alt-platform = "${self.os}-${self.alt-arch}";
46 };
47in
48self