mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
85 lines
2.3 KiB
Nix
85 lines
2.3 KiB
Nix
{
|
|
lib,
|
|
self,
|
|
helpers,
|
|
...
|
|
}:
|
|
{
|
|
perSystem =
|
|
{ pkgs, ... }:
|
|
{
|
|
checks = pkgs.callPackages ../../tests {
|
|
inherit helpers self;
|
|
};
|
|
};
|
|
|
|
# Output a build matrix for CI
|
|
flake.githubActions =
|
|
let
|
|
systemsByPrio = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
# https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job#choosing-github-hosted-runners
|
|
githubPlatforms = {
|
|
"x86_64-linux" = "ubuntu-24.04";
|
|
"aarch64-linux" = "ubuntu-24.04-arm";
|
|
"x86_64-darwin" = "macos-13";
|
|
"aarch64-darwin" = "macos-15";
|
|
};
|
|
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;
|
|
|
|
checks = 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"))
|
|
# Tests are handled by a different workflow
|
|
(builtins.filter (x: !lib.strings.hasPrefix "test-" x.name))
|
|
(lib.groupBy' (builds: x: builds ++ [ x.build ]) [ ] (x: x.name))
|
|
(lib.mapAttrsToList (name: builds: { inherit name builds; }))
|
|
|
|
# Only build one one system per check
|
|
# TODO: this is very heavy handed, maybe we want some exceptions?
|
|
(map (
|
|
matrix:
|
|
matrix
|
|
// {
|
|
builds = [
|
|
(getPrimaryBuild matrix.builds)
|
|
];
|
|
}
|
|
))
|
|
|
|
# Inject per-system attr
|
|
(map (
|
|
matrix:
|
|
matrix
|
|
// {
|
|
builds = map (build: build // { attr = "checks.${build.system}.${matrix.name}"; }) matrix.builds;
|
|
}
|
|
))
|
|
];
|
|
in
|
|
{
|
|
checksMatrix.include = checks;
|
|
};
|
|
}
|