CI rewrite for only enabled target hosts

This commit is contained in:
kat witch 2021-08-08 21:42:45 +01:00
parent 0bd5d2b237
commit 15c6902491
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
2 changed files with 13 additions and 4 deletions

View file

@ -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;
}));

View file

@ -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