mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 06:01:19 +00:00
lib/systems/parse.nix: add, use removeAbiSuffix
gnu-config will ignore the portion of a triple matching the regex `e?abi.*$` when determining the validity of a triple. In other words, `i386-linuxabichickenlips` is a valid triple. This commit updates our parsing routines to match gnu-config. I was recently surprised to discover that it is in fact possible to shoehorn ABI flavors into nix doubles in a way which preserves their property of being a (non-canonical) subset of the valid gnu-config triples. This commit is required in order to exploit that discovery to add automatic detection of ILP32 platforms (64-bit void*, 32-bit int, like the Apple Watch and MIPS n32) to Nix.
This commit is contained in:
parent
3d7a169afe
commit
20b62456f0
@ -29,6 +29,15 @@ let
|
||||
assert type.check value;
|
||||
setType type.name ({ inherit name; } // value));
|
||||
|
||||
# gnu-config will ignore the portion of a triple matching the
|
||||
# regex `e?abi.*$` when determining the validity of a triple. In
|
||||
# other words, `i386-linuxabichickenlips` is a valid triple.
|
||||
removeAbiSuffix = x:
|
||||
let match = builtins.match "(.*)e?abi.*" x;
|
||||
in if match==null
|
||||
then x
|
||||
else lib.elemAt match 0;
|
||||
|
||||
in
|
||||
|
||||
rec {
|
||||
@ -466,7 +475,7 @@ rec {
|
||||
else vendors.unknown;
|
||||
kernel = if hasPrefix "darwin" args.kernel then getKernel "darwin"
|
||||
else if hasPrefix "netbsd" args.kernel then getKernel "netbsd"
|
||||
else getKernel args.kernel;
|
||||
else getKernel (removeAbiSuffix args.kernel);
|
||||
abi =
|
||||
/**/ if args ? abi then getAbi args.abi
|
||||
else if isLinux parsed || isWindows parsed then
|
||||
|
Loading…
Reference in New Issue
Block a user