hosts: deploy in individual effects

This commit is contained in:
Max Headroom 2023-11-07 17:15:25 +01:00
parent f88749fd95
commit 7fdafae1c2

View file

@ -1,7 +1,7 @@
{ config, inputs, lib, self, withSystem, ... }:
{ config, lib, self, withSystem, ... }:
let
inherit (lib) const elem flip genAttrs mapAttrs;
inherit (lib) const elem flip genAttrs mapAttrs';
inherit (config) gods defaultEffectSystem systems;
inherit (self) nixosConfigurations;
@ -9,18 +9,20 @@ let
withEffectSystem = withSystem defaultEffectSystem;
callUpon = hours: mapAttrs (hour: const nixosConfigurations.${hour}.config.system.build.toplevel) hours;
callUpon = hour: { ${hour} = nixosConfigurations.${hour}.config.system.build.toplevel; };
in
{
herculesCI = { config, ... }: {
onPush.default.outputs.effects.callUponTheHours = withEffectSystem ({ hci-effects, ... }: let
onPush.default.outputs.effects = mapAttrs' (hour: const {
name = "deploy-${hour}";
value = withEffectSystem ({ hci-effects, ... }: let
inherit (hci-effects) runIf runCachixDeploy;
in runIf (elem config.repo.branch [ "master" "staging" ]) (
runCachixDeploy {
async = true;
deploy = {
agents = callUpon chosenHours;
agents = callUpon hour;
rollbackScript = genAttrs systems (flip withSystem ({ pkgs, ... }:
let
scheduleReboot = pkgs.writeShellScript "schedule-reboot.sh" ''
@ -58,5 +60,6 @@ in
};
}
));
}) chosenHours;
};
}