2017-07-28 20:05:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ lib }:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								with import ./parse.nix { inherit lib; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								with lib.attrsets;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								with lib.lists;
							 | 
						
					
						
							
								
									
										
										
										
											2017-05-21 13:39:23 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-11 18:30:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								let abis_ = abis; in
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-05-21 13:39:23 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								rec {
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-12 14:27:10 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  patterns = rec {
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isi686         = { cpu = cpuTypes.i686; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-06 12:57:36 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isx86_32       = { cpu = { family = "x86"; bits = 32; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isx86_64       = { cpu = { family = "x86"; bits = 64; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isPowerPC      = { cpu = cpuTypes.powerpc; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-02 01:55:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isPower        = { cpu = { family = "power"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isx86          = { cpu = { family = "x86"; }; };
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA:             ARMv8   {-A, -R, -M}
                 /    \
Mode:     Aarch32     Aarch64
             |         /   \
Encoding:   A64      A32   T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
(cherry picked from commit ba52ae50488de85a9cf60a3a04f1c9ca7122ec74)
											
										 
										
											2018-03-19 22:41:06 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isAarch32      = { cpu = { family = "arm"; bits = 32; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isAarch64      = { cpu = { family = "arm"; bits = 64; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isMips         = { cpu = { family = "mips"; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isRiscV        = { cpu = { family = "riscv"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-26 09:33:36 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isSparc        = { cpu = { family = "sparc"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isWasm         = { cpu = { family = "wasm"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-25 19:17:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isMsp430       = { cpu = { family = "msp430"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-11-02 12:47:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isVc4          = { cpu = { family = "vc4"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-12 15:09:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isAvr          = { cpu = { family = "avr"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-20 14:27:47 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isAlpha        = { cpu = { family = "alpha"; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-02 01:55:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isJavaScript   = { cpu = cpuTypes.js; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    is32bit        = { cpu = { bits = 32; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    is64bit        = { cpu = { bits = 64; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isBigEndian    = { cpu = { significantByte = significantBytes.bigEndian; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isLittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isBSD          = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isDarwin       = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-21 13:11:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isUnix         = [ isBSD isDarwin isLinux isSunOS isCygwin isRedox ];
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isMacOS        = { kernel = kernels.macos; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isiOS          = { kernel = kernels.ios; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isLinux        = { kernel = kernels.linux; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isSunOS        = { kernel = kernels.solaris; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isFreeBSD      = { kernel = kernels.freebsd; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isNetBSD       = { kernel = kernels.netbsd; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isOpenBSD      = { kernel = kernels.openbsd; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isWindows      = { kernel = kernels.windows; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isCygwin       = { kernel = kernels.windows; abi = abis.cygnus; };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isMinGW        = { kernel = kernels.windows; abi = abis.gnu; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-29 21:01:24 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isWasi         = { kernel = kernels.wasi; };
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-21 13:11:36 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isRedox        = { kernel = kernels.redox; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-02 01:55:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isGhcjs        = { kernel = kernels.ghcjs; };
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-24 13:32:18 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isGenode       = { kernel = kernels.genode; };
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-02 01:57:01 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isNone         = { kernel = kernels.none; };
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isAndroid      = [ { abi = abis.android; } { abi = abis.androideabi; } ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isMusl         = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ];
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-09 23:33:31 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    isUClibc       = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ];
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    isEfi          = map (family: { cpu.family = family; })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       [ "x86" "arm" "aarch64" ];
							 | 
						
					
						
							
								
									
										
										
										
											2017-05-21 13:39:23 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-12 14:27:10 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  matchAnyAttrs = patterns:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else matchAttrs patterns;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-03-19 22:14:45 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  predicates = mapAttrs (_: matchAnyAttrs) patterns;
							 | 
						
					
						
							
								
									
										
										
										
											2017-05-21 13:39:23 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |