2020-04-24 23:36:52 +00:00
|
|
|
{ lib }:
|
|
|
|
with import ./parse.nix { inherit lib; };
|
|
|
|
with lib.attrsets;
|
|
|
|
with lib.lists;
|
|
|
|
|
|
|
|
let abis_ = abis; in
|
|
|
|
let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in
|
|
|
|
|
|
|
|
rec {
|
2023-02-02 18:25:31 +00:00
|
|
|
# these patterns are to be matched against {host,build,target}Platform.parsed
|
2020-04-24 23:36:52 +00:00
|
|
|
patterns = rec {
|
|
|
|
isi686 = { cpu = cpuTypes.i686; };
|
|
|
|
isx86_32 = { cpu = { family = "x86"; bits = 32; }; };
|
|
|
|
isx86_64 = { cpu = { family = "x86"; bits = 64; }; };
|
|
|
|
isPower = { cpu = { family = "power"; }; };
|
2022-04-27 09:35:20 +00:00
|
|
|
isPower64 = { cpu = { family = "power"; bits = 64; }; };
|
2022-09-09 14:08:57 +00:00
|
|
|
# This ABI is the default in NixOS PowerPC64 BE, but not on mainline GCC,
|
|
|
|
# so it sometimes causes issues in certain packages that makes the wrong
|
|
|
|
# assumption on the used ABI.
|
|
|
|
isAbiElfv2 = [
|
|
|
|
{ abi = { abi = "elfv2"; }; }
|
|
|
|
{ abi = { name = "musl"; }; cpu = { family = "power"; bits = 64; }; }
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
isx86 = { cpu = { family = "x86"; }; };
|
|
|
|
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
|
2023-01-20 10:41:00 +00:00
|
|
|
isArmv7 = map ({ arch, ... }: { cpu = { inherit arch; }; })
|
|
|
|
(lib.filter (cpu: lib.hasPrefix "armv7" cpu.arch or "")
|
|
|
|
(lib.attrValues cpuTypes));
|
2020-04-24 23:36:52 +00:00
|
|
|
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
|
2022-08-12 12:06:08 +00:00
|
|
|
isAarch = { cpu = { family = "arm"; }; };
|
2022-09-09 14:08:57 +00:00
|
|
|
isMicroBlaze = { cpu = { family = "microblaze"; }; };
|
2020-04-24 23:36:52 +00:00
|
|
|
isMips = { cpu = { family = "mips"; }; };
|
2022-03-30 09:31:56 +00:00
|
|
|
isMips32 = { cpu = { family = "mips"; bits = 32; }; };
|
|
|
|
isMips64 = { cpu = { family = "mips"; bits = 64; }; };
|
|
|
|
isMips64n32 = { cpu = { family = "mips"; bits = 64; }; abi = { abi = "n32"; }; };
|
|
|
|
isMips64n64 = { cpu = { family = "mips"; bits = 64; }; abi = { abi = "64"; }; };
|
2020-11-15 13:44:38 +00:00
|
|
|
isMmix = { cpu = { family = "mmix"; }; };
|
2020-04-24 23:36:52 +00:00
|
|
|
isRiscV = { cpu = { family = "riscv"; }; };
|
2022-04-27 09:35:20 +00:00
|
|
|
isRiscV32 = { cpu = { family = "riscv"; bits = 32; }; };
|
|
|
|
isRiscV64 = { cpu = { family = "riscv"; bits = 64; }; };
|
2022-06-16 17:23:12 +00:00
|
|
|
isRx = { cpu = { family = "rx"; }; };
|
2020-04-24 23:36:52 +00:00
|
|
|
isSparc = { cpu = { family = "sparc"; }; };
|
|
|
|
isWasm = { cpu = { family = "wasm"; }; };
|
|
|
|
isMsp430 = { cpu = { family = "msp430"; }; };
|
|
|
|
isVc4 = { cpu = { family = "vc4"; }; };
|
|
|
|
isAvr = { cpu = { family = "avr"; }; };
|
|
|
|
isAlpha = { cpu = { family = "alpha"; }; };
|
2020-11-19 00:13:47 +00:00
|
|
|
isOr1k = { cpu = { family = "or1k"; }; };
|
2021-08-05 21:33:18 +00:00
|
|
|
isM68k = { cpu = { family = "m68k"; }; };
|
|
|
|
isS390 = { cpu = { family = "s390"; }; };
|
2023-01-20 10:41:00 +00:00
|
|
|
isS390x = { cpu = { family = "s390"; bits = 64; }; };
|
2020-04-24 23:36:52 +00:00
|
|
|
isJavaScript = { cpu = cpuTypes.js; };
|
|
|
|
|
|
|
|
is32bit = { cpu = { bits = 32; }; };
|
|
|
|
is64bit = { cpu = { bits = 64; }; };
|
2023-01-11 07:51:40 +00:00
|
|
|
isILP32 = map (a: { abi = { abi = a; }; }) [ "n32" "ilp32" "x32" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
isBigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; };
|
|
|
|
isLittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };
|
|
|
|
|
|
|
|
isBSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
|
|
|
|
isDarwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
|
2020-08-20 17:08:02 +00:00
|
|
|
isUnix = [ isBSD isDarwin isLinux isSunOS isCygwin isRedox ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
isMacOS = { kernel = kernels.macos; };
|
|
|
|
isiOS = { kernel = kernels.ios; };
|
|
|
|
isLinux = { kernel = kernels.linux; };
|
|
|
|
isSunOS = { kernel = kernels.solaris; };
|
2022-11-21 17:40:18 +00:00
|
|
|
isFreeBSD = { kernel = { name = "freebsd"; }; };
|
2020-04-24 23:36:52 +00:00
|
|
|
isNetBSD = { kernel = kernels.netbsd; };
|
|
|
|
isOpenBSD = { kernel = kernels.openbsd; };
|
|
|
|
isWindows = { kernel = kernels.windows; };
|
|
|
|
isCygwin = { kernel = kernels.windows; abi = abis.cygnus; };
|
|
|
|
isMinGW = { kernel = kernels.windows; abi = abis.gnu; };
|
|
|
|
isWasi = { kernel = kernels.wasi; };
|
2020-08-20 17:08:02 +00:00
|
|
|
isRedox = { kernel = kernels.redox; };
|
2020-04-24 23:36:52 +00:00
|
|
|
isGhcjs = { kernel = kernels.ghcjs; };
|
|
|
|
isGenode = { kernel = kernels.genode; };
|
|
|
|
isNone = { kernel = kernels.none; };
|
|
|
|
|
|
|
|
isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
|
2022-09-09 14:08:57 +00:00
|
|
|
isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf gnuabielfv1 gnuabielfv2 ];
|
2022-03-30 09:31:56 +00:00
|
|
|
isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf muslabin32 muslabi64 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
isEfi = [
|
|
|
|
{ cpu = { family = "arm"; version = "6"; }; }
|
|
|
|
{ cpu = { family = "arm"; version = "7"; }; }
|
|
|
|
{ cpu = { family = "arm"; version = "8"; }; }
|
|
|
|
{ cpu = { family = "riscv"; }; }
|
|
|
|
{ cpu = { family = "x86"; }; }
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
matchAnyAttrs = patterns:
|
|
|
|
if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
|
|
|
|
else matchAttrs patterns;
|
|
|
|
|
|
|
|
predicates = mapAttrs (_: matchAnyAttrs) patterns;
|
2023-02-02 18:25:31 +00:00
|
|
|
|
|
|
|
# these patterns are to be matched against the entire
|
|
|
|
# {host,build,target}Platform structure; they include a `parsed={}` marker so
|
|
|
|
# that `lib.meta.availableOn` can distinguish them from the patterns which
|
|
|
|
# apply only to the `parsed` field.
|
|
|
|
|
|
|
|
platformPatterns = mapAttrs (_: p: { parsed = {}; } // p) {
|
|
|
|
isStatic = { isStatic = true; };
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|