improve systems name implementation

This commit is contained in:
Emile Clark-Boman 2025-11-05 16:29:40 +10:00
parent e9f735e0dd
commit a07ef07998

View file

@ -1,27 +1,50 @@
{...}: rec { {lib, ...}: let
# XXX: TODO: Move these helper functions into their own modules
listToTrivialAttrs = values:
builtins.listToAttrs (builtins.map (x: {
name = x;
value = x;
})
values);
attrVals = lib.attrsets.attrVals;
in rec {
toSystemName = arch: platform: "${arch}-${platform}";
listsToSystemNames = archs: platforms:
lib.lists.crossLists (arch: platform: toSystemName arch platform)
[
(attrVals archs)
(attrVals platforms)
];
# REF: https://github.com/nix-systems/nix-systems # REF: https://github.com/nix-systems/nix-systems
archs = { archs = listToTrivialAttrs arch;
x86_64 = "x86_64"; arch = [
aarch64 = "aarch64"; "x86_64"
riscv64 = "riscv64"; "aarch64"
}; "riscv64"
];
osnames = { # REF: https://github.com/nix-systems/nix-systems
linux = "linux"; platforms = listToTrivialAttrs platform;
darwin = "darwin"; platform = [
}; "linux"
"darwin"
];
systemName = arch: osname: "${arch}-${osname}"; # Nix System Identifier Lists - Default Supported Systems
systems = systemsDefault;
systemsDefault = systemsX86_64 // systemsAArch64;
systems = let # Nix System Identifier Lists - All Potential Systems
mkSystem = arch: osname: let x = systemName arch osname; in {x = x;}; systemsAll = listsToSystemNames archs platforms;
in
with archs; # Nix System Identifier Lists - Platform Specific
with osnames; { systemsLinux = listsToSystemNames archs [platform.linux];
inherit (mkSystem x86_64 linux); systemsDarwin = listsToSystemNames archs [platform.darwin];
inherit (mkSystem x86_64 darwin);
inherit (mkSystem aarch64 linux); # Nix System Identifier Lists - Architecture Specific
inherit (mkSystem aarch64 darwin); systemsX86_64 = listsToSystemNames [arch.x86_64] platforms;
inherit (mkSystem riscv64 linux); systemsAArch64 = listsToSystemNames [arch.aarch64] platforms;
}; systemsRiscV64 = listsToSystemNames [arch.riscv64] platforms;
} }