From dbc4378f90f390e5ab1eba38de5d47a639017162 Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Sun, 7 Jul 2024 22:50:46 -0400 Subject: [PATCH] per-system derivations for hydra agg job Signed-off-by: ahuston-0 --- flake.nix | 2 +- hydra/jobs.nix | 34 ++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 3e6367d..d9ca153 100644 --- a/flake.nix +++ b/flake.nix @@ -161,7 +161,7 @@ rec { 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); nixosConfigurations = genSystems inputs src (src + "/systems"); diff --git a/hydra/jobs.nix b/hydra/jobs.nix index 73bf17c..e8d9279 100644 --- a/hydra/jobs.nix +++ b/hydra/jobs.nix @@ -1,27 +1,45 @@ -{ inputs, outputs }: +{ + inputs, + outputs, + systems, +}: let - inherit (inputs.nixpkgs.lib) mapAttrs mapAttrsToList; + inherit (inputs.nixpkgs) lib; pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; getCfg = _: cfg: cfg.config.system.build.toplevel; 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 rec { inherit (outputs) formatter devShells checks; - host = mapAttrs getCfg outputs.nixosConfigurations; + host = lib.mapAttrs getCfg outputs.nixosConfigurations; hosts = pkgs.releaseTools.aggregate { name = "hosts"; - constituents = mapAttrsToList hostToAgg host; + constituents = lib.mapAttrsToList hostToAgg host; }; devChecks = pkgs.releaseTools.aggregate { name = "devChecks"; - constituents = [ - formatter.x86_64-linux - devShells.x86_64-linux - checks.x86_64-linux + constituents = lib.flatten [ + (mapSystems { check = formatter; }) + (mapSystems { + check = checks; + postfix = "pre-commit-check"; + }) + (mapSystems { + check = devShells; + postfix = "default"; + }) ]; }; }