From 15c6902491903f7feb8afef0d6373e28a9435223 Mon Sep 17 00:00:00 2001 From: kat witch Date: Sun, 8 Aug 2021 21:42:45 +0100 Subject: [PATCH] CI rewrite for only enabled target hosts --- ci/hosts.nix | 8 ++++++-- ci/niv-cron.nix | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ci/hosts.nix b/ci/hosts.nix index 0cde88b5..0dccebe4 100644 --- a/ci/hosts.nix +++ b/ci/hosts.nix @@ -14,8 +14,12 @@ ''; }; - jobs = let hostnames = remove "dummy" (lib.attrNames (import ../.).hosts); - in mapAttrs' (k: nameValuePair "host-${k}") (genAttrs hostnames (host: { + jobs = let main = (import ../.); + hosts = main.network.nodes; + targets = main.deploy.targets; + enabledTargets = filterAttrs (_: v: v.enable) main.deploy.targets; + enabledHosts = concatLists (mapAttrsToList (targetName: target: target.nodeNames) enabledTargets); + in mapAttrs' (k: nameValuePair "host-${k}") (genAttrs enabledHosts (host: { tasks.${host}.inputs = channels.nixfiles.network.nodes.${host}.deploy.system; })); diff --git a/ci/niv-cron.nix b/ci/niv-cron.nix index d48de118..44922670 100644 --- a/ci/niv-cron.nix +++ b/ci/niv-cron.nix @@ -46,8 +46,13 @@ with lib; { }; displayName = "niv update build"; environment = [ "OPENSSH_PRIVATE_KEY" "CACHIX_SIGNING_KEY" "GITHUB_REF" ]; - command = let hostnames = remove "dummy" (lib.attrNames (import ../.).hosts); - hostBuildString = concatMapStrings (host: "nix build -Lf . network.nodes.${host}.deploy.system && nix-collect-garbage -d && " ) hostnames; in '' + command = let main = (import ../.); + hosts = main.network.nodes; + targets = main.deploy.targets; + enabledTargets = filterAttrs (_: v: v.enable) main.deploy.targets; + enabledHosts = concatLists (mapAttrsToList (targetName: target: target.nodeNames) enabledTargets); + hostBuildString = concatMapStrings (host: "nix build -Lf . network.nodes.${host}.deploy.system && nix-collect-garbage -d && " ) enabledHosts; + in '' # ${toString builtins.currentTime} if [[ -n $OPENSSH_PRIVATE_KEY ]]; then mkdir ~/.ssh