2017-07-28 18:05:35 -06:00
|
|
|
{ lib }:
|
|
|
|
with import ./parse.nix { inherit lib; };
|
|
|
|
with lib.attrsets;
|
|
|
|
with lib.lists;
|
2017-05-21 11:39:23 -06:00
|
|
|
|
|
|
|
rec {
|
2017-06-12 11:27:10 -06:00
|
|
|
patterns = rec {
|
2017-05-21 11:39:23 -06:00
|
|
|
i686 = { cpu = cpuTypes.i686; };
|
|
|
|
x86_64 = { cpu = cpuTypes.x86_64; };
|
2017-07-09 13:12:32 -06:00
|
|
|
PowerPC = { cpu = cpuTypes.powerpc; };
|
2017-05-22 15:09:06 -06:00
|
|
|
x86 = { cpu = { family = "x86"; }; };
|
2017-05-21 11:39:23 -06:00
|
|
|
Arm = { cpu = { family = "arm"; }; };
|
2017-08-24 05:43:57 -06:00
|
|
|
Aarch64 = { cpu = { family = "aarch64"; }; };
|
2017-05-21 11:39:23 -06:00
|
|
|
Mips = { cpu = { family = "mips"; }; };
|
2018-01-25 14:30:03 -07:00
|
|
|
RiscV = { cpu = { family = "riscv"; }; };
|
|
|
|
Wasm = { cpu = { family = "wasm"; }; };
|
|
|
|
|
|
|
|
"32bit" = { cpu = { bits = 32; }; };
|
|
|
|
"64bit" = { cpu = { bits = 64; }; };
|
2017-05-21 11:39:23 -06:00
|
|
|
BigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; };
|
|
|
|
LittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };
|
|
|
|
|
|
|
|
BSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
|
2018-03-18 22:16:25 -06:00
|
|
|
Darwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
|
2017-07-03 06:31:25 -06:00
|
|
|
Unix = [ BSD Darwin Linux SunOS Hurd Cygwin ];
|
2017-05-21 11:39:23 -06:00
|
|
|
|
2018-03-18 22:16:25 -06:00
|
|
|
MacOS = { kernel = kernels.macos; };
|
|
|
|
iOS = { kernel = kernels.ios; };
|
2017-05-21 11:39:23 -06:00
|
|
|
Linux = { kernel = kernels.linux; };
|
|
|
|
SunOS = { kernel = kernels.solaris; };
|
|
|
|
FreeBSD = { kernel = kernels.freebsd; };
|
2017-05-22 10:42:03 -06:00
|
|
|
Hurd = { kernel = kernels.hurd; };
|
2017-05-21 11:39:23 -06:00
|
|
|
NetBSD = { kernel = kernels.netbsd; };
|
|
|
|
OpenBSD = { kernel = kernels.openbsd; };
|
|
|
|
Windows = { kernel = kernels.windows; };
|
|
|
|
Cygwin = { kernel = kernels.windows; abi = abis.cygnus; };
|
|
|
|
MinGW = { kernel = kernels.windows; abi = abis.gnu; };
|
2018-02-11 13:20:14 -07:00
|
|
|
|
2017-02-16 22:36:10 -07:00
|
|
|
Android = [ { abi = abis.android; } { abi = abis.androideabi; } ];
|
2018-02-11 13:20:14 -07:00
|
|
|
Musl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ];
|
2018-02-24 08:37:54 -07:00
|
|
|
|
|
|
|
Kexecable = map (family: { kernel = kernels.linux; cpu.family = family; })
|
|
|
|
[ "x86" "arm" "aarch64" "mips" ];
|
2018-02-24 20:15:48 -07:00
|
|
|
Efi = map (family: { cpu.family = family; })
|
|
|
|
[ "x86" "arm" "aarch64" ];
|
2018-02-24 21:05:08 -07:00
|
|
|
Seccomputable = map (family: { kernel = kernels.linux; cpu.family = family; })
|
|
|
|
[ "x86" "arm" "aarch64" "mips" ];
|
2017-05-21 11:39:23 -06:00
|
|
|
};
|
|
|
|
|
2017-06-12 11:27:10 -06:00
|
|
|
matchAnyAttrs = patterns:
|
|
|
|
if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
|
|
|
|
else matchAttrs patterns;
|
|
|
|
|
2017-05-21 11:39:23 -06:00
|
|
|
predicates = mapAttrs'
|
2017-06-12 11:27:10 -06:00
|
|
|
(name: value: nameValuePair ("is" + name) (matchAnyAttrs value))
|
2017-05-21 11:39:23 -06:00
|
|
|
patterns;
|
|
|
|
}
|