per-system derivations for hydra agg job

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
ahuston-0 2024-07-07 22:50:46 -04:00 committed by Alice Huston
parent f5dc1046eb
commit dbc4378f90
2 changed files with 27 additions and 9 deletions

View File

@ -161,7 +161,7 @@
rec { rec {
inherit lib; # for allowing use of custom functions in nix repl inherit lib; # for allowing use of custom functions in nix repl
hydraJobs = import ./hydra/jobs.nix { inherit inputs outputs; }; hydraJobs = import ./hydra/jobs.nix { inherit inputs outputs systems; };
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
nixosConfigurations = genSystems inputs src (src + "/systems"); nixosConfigurations = genSystems inputs src (src + "/systems");

View File

@ -1,27 +1,45 @@
{ inputs, outputs }: {
inputs,
outputs,
systems,
}:
let let
inherit (inputs.nixpkgs.lib) mapAttrs mapAttrsToList; inherit (inputs.nixpkgs) lib;
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
getCfg = _: cfg: cfg.config.system.build.toplevel; getCfg = _: cfg: cfg.config.system.build.toplevel;
hostToAgg = _: cfg: cfg; hostToAgg = _: cfg: cfg;
# get per-system check derivation (with optional postfix)
mapSystems =
{
check,
postfix ? "",
}:
(map (system: if postfix == "" then check.${system} else check.${system}.${postfix}) systems);
in in
rec { rec {
inherit (outputs) formatter devShells checks; inherit (outputs) formatter devShells checks;
host = mapAttrs getCfg outputs.nixosConfigurations; host = lib.mapAttrs getCfg outputs.nixosConfigurations;
hosts = pkgs.releaseTools.aggregate { hosts = pkgs.releaseTools.aggregate {
name = "hosts"; name = "hosts";
constituents = mapAttrsToList hostToAgg host; constituents = lib.mapAttrsToList hostToAgg host;
}; };
devChecks = pkgs.releaseTools.aggregate { devChecks = pkgs.releaseTools.aggregate {
name = "devChecks"; name = "devChecks";
constituents = [ constituents = lib.flatten [
formatter.x86_64-linux (mapSystems { check = formatter; })
devShells.x86_64-linux (mapSystems {
checks.x86_64-linux check = checks;
postfix = "pre-commit-check";
})
(mapSystems {
check = devShells;
postfix = "default";
})
]; ];
}; };
} }