project-wide: Correctness

This commit is contained in:
kat witch 2021-03-29 03:06:29 +01:00
parent 69c2dcf7f2
commit 1868690888
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72

View file

@ -1,4 +1,4 @@
{ pkgs, hosts, sources, groups, group ? "all", host ? null}: { pkgs, hosts, sources, groups }:
with pkgs.lib; with pkgs.lib;
@ -11,10 +11,10 @@ let
specialArgs = { }; specialArgs = { };
}).config; }).config;
tf = tfEval ({ config, ... }: { tf = makeOverridable ({ group ? null, host ? null }: tfEval ({ config, ... }: {
deps = { deps = {
enable = true; enable = true;
select.hclPaths = (map (name: config.resources."${name}_system_switch".out.hclPathStr) (if host != null then [ host ] else groups.${group} )); select.hclPaths = (map (name: config.resources."${name}_system_switch".out.hclPathStr) (if host != null then [ host ] else (if group != null then groups.${group} else []) ));
}; };
state = { file = toString ../private/files/tf/terraform.tfstate; }; state = { file = toString ../private/files/tf/terraform.tfstate; };
@ -22,7 +22,7 @@ let
runners.lazy = { runners.lazy = {
file = ../.; file = ../.;
args = [ "--show-trace" ]; args = [ "--show-trace" ];
attrPrefix = let attr = if host != null then "host.${host}" else "group.${group}"; in "deploy.${attr}.runners.run."; attrPrefix = let attr = if host != null then "host.${host}" else if group != null then "group.${group}" else "tf"; in "deploy.${attr}.runners.run.";
}; };
terraform = { terraform = {
@ -95,9 +95,9 @@ let
triggers.copy.yule = athame.refAttr "id"; triggers.copy.yule = athame.refAttr "id";
triggers.secrets.yule = athame.refAttr "id"; triggers.secrets.yule = athame.refAttr "id";
}; };
}); })) {};
in { in {
inherit tf; inherit tf;
group = genAttrs (attrNames groups) (group: (import ./deploy.nix { inherit pkgs hosts sources groups group; }).tf); group = genAttrs (attrNames groups) (group: (tf.override { inherit group; }));
host = genAttrs (attrNames hosts) (host: (import ./deploy.nix { inherit pkgs hosts sources groups host; }).tf); host = genAttrs (attrNames hosts) (host: (tf.override { inherit host; }));
} }