about summary refs log tree commit diff
path: root/lib/systems/inspect.nix
blob: 241c9365f2e7add061e9cbc59aa5bb1bd3d63f72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
with import ./parse.nix;
with import ../attrsets.nix;

rec {
  patterns = {
    "32bit"      = { cpu = { bits = 32; }; };
    "64bit"      = { cpu = { bits = 64; }; };
    i686         = { cpu = cpuTypes.i686; };
    x86_64       = { cpu = cpuTypes.x86_64; };
    x86          = { cpu = { family = "x86"; }; };
    Arm          = { cpu = { family = "arm"; }; };
    Mips         = { cpu = { family = "mips"; }; };
    BigEndian    = { cpu = { significantByte = significantBytes.bigEndian; }; };
    LittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };

    Unix         = { kernel = { families = { inherit (kernelFamilies) unix; }; }; };
    BSD          = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };

    Darwin       = { kernel = kernels.darwin; };
    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; };

    Arm32        = recursiveUpdate patterns.Arm patterns."32bit";
    Arm64        = recursiveUpdate patterns.Arm patterns."64bit";
  };

  predicates = mapAttrs'
    (name: value: nameValuePair ("is" + name) (matchAttrs value))
    patterns;
}