git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitbbfa2f97014de8aa928485a07b722d792b09238f authorJohn Ericson <John.Ericson@Obsidian.Systems> dateMon 19 Mar 2018, 00:16 (9 years ago) parent2fa2197
2 files changed+16−6
lib/systems/inspect.nix+3−1 lib/systems/parse.nix+13−5
lib/systems/inspect.nix+3−1
@@ -21,9 +21,11 @@ rec {
2121 LittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };
2222
2323 BSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
24+ Darwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
2425 Unix = [ BSD Darwin Linux SunOS Hurd Cygwin ];
2526
26− Darwin = { kernel = kernels.darwin; };
27+ MacOS = { kernel = kernels.macos; };
28+ iOS = { kernel = kernels.ios; };
2729 Linux = { kernel = kernels.linux; };
2830 SunOS = { kernel = kernels.solaris; };
2931 FreeBSD = { kernel = kernels.freebsd; };
lib/systems/parse.nix+13−5
@@ -134,6 +134,7 @@ rec {
134134
135135 kernelFamilies = setTypes types.openKernelFamily {
136136 bsd = {};
137+ darwin = {};
137138 };
138139
139140 ################################################################################
@@ -149,7 +150,10 @@ rec {
149150 types.kernel = enum (attrValues kernels);
150151
151152 kernels = with execFormats; with kernelFamilies; setTypes types.openKernel {
152− darwin = { execFormat = macho; families = { }; };
153+ # TODO(@Ericson2314): Don't want to mass-rebuild yet to keeping 'darwin' as
154+ # the nnormalized name for macOS.
155+ macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
156+ ios = { execFormat = macho; families = { inherit darwin; }; };
153157 freebsd = { execFormat = elf; families = { inherit bsd; }; };
154158 hurd = { execFormat = elf; families = { }; };
155159 linux = { execFormat = elf; families = { }; };
@@ -159,9 +163,13 @@ rec {
159163 solaris = { execFormat = elf; families = { }; };
160164 windows = { execFormat = pe; families = { }; };
161165 } // { # aliases
166+ # 'darwin' is the kernel for all of them. We choose macOS by default.
167+ darwin = kernels.macos;
162168 # TODO(@Ericson2314): Handle these Darwin version suffixes more generally.
163− darwin10 = kernels.darwin;
164− darwin14 = kernels.darwin;
169+ darwin10 = kernels.macos;
170+ darwin14 = kernels.macos;
171+ watchos = kernels.ios;
172+ tvos = kernels.ios;
165173 win32 = kernels.windows;
166174 };
167175
@@ -263,8 +271,8 @@ rec {
263271 mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
264272
265273 doubleFromSystem = { cpu, vendor, kernel, abi, ... }:
266− if abi == abis.cygnus
267− then "${cpu.name}-cygwin"
274+ /**/ if abi == abis.cygnus then "${cpu.name}-cygwin"
275+ else if kernel.families ? darwin then "${cpu.name}-darwin"
268276 else "${cpu.name}-${kernel.name}";
269277
270278 tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let