1let inherit (import ../attrsets.nix) mapAttrs; in
2
3rec {
4 doubles = import ./doubles.nix;
5 parse = import ./parse.nix;
6 inspect = import ./inspect.nix;
7 platforms = import ./platforms.nix;
8 examples = import ./examples.nix;
9
10 # Elaborate a `localSystem` or `crossSystem` so that it contains everything
11 # necessary.
12 #
13 # `parsed` is inferred from args, both because there are two options with one
14 # clearly prefered, and to prevent cycles. A simpler fixed point where the RHS
15 # always just used `final.*` would fail on both counts.
16 elaborate = args: let
17 final = {
18 # Prefer to parse `config` as it is strictly more informative.
19 parsed = parse.mkSystemFromString (if args ? config then args.config else args.system);
20 # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.
21 system = parse.doubleFromSystem final.parsed;
22 config = parse.tripleFromSystem final.parsed;
23 # Just a guess, based on `system`
24 platform = platforms.selectBySystem final.system;
25 libc =
26 /**/ if final.isDarwin then "libSystem"
27 else if final.isMinGW then "msvcrt"
28 else if final.isLinux then "glibc"
29 # TODO(@Ericson2314) think more about other operating systems
30 else "native/impure";
31 } // mapAttrs (n: v: v final.parsed) inspect.predicates
32 // args;
33 in final;
34}