mkSkeletonFromList
lib.systems.parse.mkSkeletonFromList
Docs pulled from | This Revision | 1 day ago
Contribute
Enhance the ecosystem with your expertise! Contribute to fill the gaps in documentation. Your input can make a difference.
Noogle detected
Implementation
The following is the current implementation of this function.
l:
{
"1" =
let
firstComponent = head l;
in
if firstComponent == "avr" then
{
cpu = firstComponent;
kernel = "none";
abi = "unknown";
}
else
throw "system string '${lib.concatStringsSep "-" l}' with 1 component is ambiguous";
"2" = # We only do 2-part hacks for things Nix already supports
let
secondComponent = elemAt l 1;
in
if secondComponent == "cygwin" then
mkSkeletonFromList [
(head l)
"pc"
secondComponent
]
# MSVC ought to be the default ABI so this case isn't needed. But then it
# becomes difficult to handle the gnu* variants for Aarch32 correctly for
# minGW. So it's easier to make gnu* the default for the MinGW, but
# hack-in MSVC for the non-MinGW case right here.
else if secondComponent == "windows" then
{
cpu = head l;
kernel = secondComponent;
abi = "msvc";
}
else if secondComponent == "elf" then
{
cpu = head l;
vendor = "unknown";
kernel = "none";
abi = secondComponent;
}
else
{
cpu = head l;
kernel = secondComponent;
};
"3" =
let
secondComponent = elemAt l 1;
thirdComponent = elemAt l 2;
in
# cpu-kernel-environment
if secondComponent == "linux" || elem thirdComponent linuxComponents then
{
cpu = head l;
kernel = secondComponent;
abi = thirdComponent;
vendor = "unknown";
}
# cpu-vendor-os
else if
secondComponent == "apple"
|| elem thirdComponent appleComponents
|| hasPrefix "freebsd" thirdComponent
|| hasPrefix "netbsd" thirdComponent
|| hasPrefix "openbsd" thirdComponent
|| hasPrefix "genode" thirdComponent
|| hasPrefix "wasm32" (head l)
then
{
cpu = head l;
vendor = secondComponent;
kernel =
if thirdComponent == "mingw32" then
"windows" # autotools breaks on -gnu for window
else
thirdComponent;
}
# lots of tools expect a triplet for Cygwin, even though the vendor is just "pc"
else if thirdComponent == "cygwin" then
{
cpu = head l;
vendor = secondComponent;
kernel = thirdComponent;
}
else
throw "system string '${lib.concatStringsSep "-" l}' with 3 components is ambiguous";
"4" = {
cpu = head l;
vendor = elemAt l 1;
kernel = elemAt l 2;
abi = elemAt l 3;
};
}
.${toString (length l)}
or (throw "system string '${lib.concatStringsSep "-" l}' has invalid number of hyphen-separated components")