nixpkgs/lib/systems/inspect.nix
John Ericson bbfa2f9701 lib: Split Darwin into macOS and iOS
I noticed LLVM accepts `ios` as its own OS in platform triples; a
recent change as far as I know. I see it also accepts `macos*` for macOS
(formerly OS X). If it's now customary to distinguish iOS like so
(rather than guessing from the aarch, lets add both so our OSes are
still disjoint, and make Darwin a family instead.

But changing the config everywhere would probably be a mass rebuild, and
I'm not sure how well other software supports OSes besides "darwin", so
I'm keeping that the default name for macOS for now.
2018-03-19 12:02:49 -04:00

58 lines
2.4 KiB
Nix

{ lib }:
with import ./parse.nix { inherit lib; };
with lib.attrsets;
with lib.lists;
rec {
patterns = rec {
i686 = { cpu = cpuTypes.i686; };
x86_64 = { cpu = cpuTypes.x86_64; };
PowerPC = { cpu = cpuTypes.powerpc; };
x86 = { cpu = { family = "x86"; }; };
Arm = { cpu = { family = "arm"; }; };
Aarch64 = { cpu = { family = "aarch64"; }; };
Mips = { cpu = { family = "mips"; }; };
RiscV = { cpu = { family = "riscv"; }; };
Wasm = { cpu = { family = "wasm"; }; };
"32bit" = { cpu = { bits = 32; }; };
"64bit" = { cpu = { bits = 64; }; };
BigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; };
LittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };
BSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
Darwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
Unix = [ BSD Darwin Linux SunOS Hurd Cygwin ];
MacOS = { kernel = kernels.macos; };
iOS = { kernel = kernels.ios; };
Linux = { kernel = kernels.linux; };
SunOS = { kernel = kernels.solaris; };
FreeBSD = { kernel = kernels.freebsd; };
Hurd = { kernel = kernels.hurd; };
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; };
Android = [ { abi = abis.android; } { abi = abis.androideabi; } ];
Musl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ];
Kexecable = map (family: { kernel = kernels.linux; cpu.family = family; })
[ "x86" "arm" "aarch64" "mips" ];
Efi = map (family: { cpu.family = family; })
[ "x86" "arm" "aarch64" ];
Seccomputable = map (family: { kernel = kernels.linux; cpu.family = family; })
[ "x86" "arm" "aarch64" "mips" ];
};
matchAnyAttrs = patterns:
if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
else matchAttrs patterns;
predicates = mapAttrs'
(name: value: nameValuePair ("is" + name) (matchAnyAttrs value))
patterns;
}