2024-10-18 09:44:59 +01:00
|
|
|
{
|
2025-05-25 17:56:54 +01:00
|
|
|
lib,
|
2024-10-18 09:44:59 +01:00
|
|
|
self,
|
|
|
|
helpers,
|
|
|
|
...
|
|
|
|
}:
|
2023-12-06 13:09:26 +01:00
|
|
|
{
|
|
|
|
perSystem =
|
2025-01-19 12:55:15 +00:00
|
|
|
{ pkgs, ... }:
|
2023-12-06 13:09:26 +01:00
|
|
|
{
|
2025-02-22 16:02:13 +00:00
|
|
|
checks = pkgs.callPackages ../../tests {
|
2025-01-19 12:55:15 +00:00
|
|
|
inherit helpers self;
|
2024-10-18 09:44:59 +01:00
|
|
|
};
|
2024-01-06 17:57:24 +01:00
|
|
|
};
|
2025-05-25 17:12:19 +01:00
|
|
|
|
|
|
|
# Output a build matrix for CI
|
2025-05-25 23:20:50 +01:00
|
|
|
flake.githubActions.matrix =
|
|
|
|
let
|
|
|
|
systemsByPrio = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"aarch64-darwin"
|
|
|
|
];
|
|
|
|
githubPlatforms = {
|
|
|
|
"x86_64-linux" = "ubuntu-24.04";
|
|
|
|
"x86_64-darwin" = "macos-13";
|
|
|
|
"aarch64-darwin" = "macos-14";
|
|
|
|
"aarch64-linux" = "ubuntu-24.04-arm";
|
|
|
|
};
|
|
|
|
toGithubBuild = system: {
|
|
|
|
inherit system;
|
|
|
|
runner = githubPlatforms.${system} or (throw "System not supported by GitHub Actions: ${system}");
|
|
|
|
};
|
|
|
|
getPrimaryBuild =
|
|
|
|
platforms:
|
|
|
|
let
|
|
|
|
systems = builtins.catAttrs "system" platforms;
|
|
|
|
system = lib.lists.findFirst (
|
|
|
|
system: builtins.elem system systems
|
|
|
|
) (throw "No supported system found!") systemsByPrio;
|
|
|
|
in
|
|
|
|
toGithubBuild system;
|
|
|
|
in
|
|
|
|
lib.pipe self.checks [
|
|
|
|
(lib.mapAttrsRecursiveCond (x: !lib.isDerivation x) (
|
|
|
|
loc: _: {
|
|
|
|
_type = "check";
|
|
|
|
build = toGithubBuild (builtins.head loc);
|
|
|
|
name = lib.attrsets.showAttrPath (builtins.tail loc);
|
|
|
|
}
|
|
|
|
))
|
|
|
|
(lib.collect (lib.isType "check"))
|
|
|
|
(lib.groupBy' (acc: x: acc ++ [ x.build ]) [ ] (x: x.attr))
|
|
|
|
(lib.mapAttrsToList (attr: builds: { inherit attr builds; }))
|
|
|
|
|
|
|
|
# Only build one one system for non-test attrs
|
|
|
|
# TODO: this is very heavy handed, maybe we want some exceptions?
|
|
|
|
(map (
|
|
|
|
matrix:
|
|
|
|
matrix
|
|
|
|
// lib.optionalAttrs (!lib.strings.hasPrefix "test-" matrix.name) {
|
|
|
|
builds = [
|
|
|
|
(getPrimaryBuild matrix.builds)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
))
|
|
|
|
|
|
|
|
# Inject per-system attr
|
|
|
|
(map (
|
|
|
|
matrix:
|
|
|
|
matrix
|
|
|
|
// {
|
|
|
|
builds = map (
|
|
|
|
build:
|
|
|
|
build
|
|
|
|
// {
|
|
|
|
attr = "checks.${build.system}.${matrix.name}";
|
|
|
|
}
|
|
|
|
) matrix.builds;
|
|
|
|
}
|
|
|
|
))
|
|
|
|
];
|
2023-12-06 13:09:26 +01:00
|
|
|
}
|