mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
Deploy target autodefinition overhaul
This commit is contained in:
parent
6b9b0ba3cf
commit
7ad716b827
3 changed files with 18 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
{ lib, config, ... }: with lib; {
|
{ lib, config, ... }: with lib; {
|
||||||
|
deploy.targets.dummy.enable = false;
|
||||||
network.nodes.dummy = {
|
network.nodes.dummy = {
|
||||||
imports = lib.hostImport "dummy";
|
imports = lib.hostImport "dummy";
|
||||||
networking = {
|
networking = {
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ in {
|
||||||
targets = let
|
targets = let
|
||||||
type = types.submodule ({ config, name, ... }: {
|
type = types.submodule ({ config, name, ... }: {
|
||||||
options = {
|
options = {
|
||||||
|
enable = mkEnableOption "Enable the target" // { default = true; };
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = name;
|
default = name;
|
||||||
|
|
@ -99,13 +100,22 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
|
deploy.targets = let
|
||||||
|
nodeNames = attrNames config.network.nodes;
|
||||||
|
targets = config.deploy.targets;
|
||||||
|
explicitlyDefinedHosts = concatLists (mapAttrsToList (targetName: target: remove targetName target.nodeNames) config.deploy.targets);
|
||||||
|
in genAttrs nodeNames ( nodeName: {
|
||||||
|
enable = mkDefault (! elem nodeName explicitlyDefinedHosts);
|
||||||
|
nodeNames = singleton nodeName;
|
||||||
|
});
|
||||||
|
|
||||||
runners = {
|
runners = {
|
||||||
run = mkMerge (mapAttrsToList (targetName: target: mapAttrs' (k: run:
|
run = mkMerge (mapAttrsToList (targetName: target: mapAttrs' (k: run:
|
||||||
nameValuePair run.name run.set
|
nameValuePair run.name run.set
|
||||||
) target.tf.runners.run) cfg.targets);
|
) target.tf.runners.run) (filterAttrs (_: v: v.enable) cfg.targets));
|
||||||
lazy.run = mkMerge (mapAttrsToList (targetName: target: mapAttrs' (k: run:
|
lazy.run = mkMerge (mapAttrsToList (targetName: target: mapAttrs' (k: run:
|
||||||
nameValuePair run.name run.set
|
nameValuePair run.name run.set
|
||||||
) target.tf.runners.lazy.run) cfg.targets);
|
) target.tf.runners.lazy.run) (filterAttrs (_: v: v.enable) cfg.targets));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
default.nix
10
default.nix
|
|
@ -38,12 +38,12 @@ let
|
||||||
|
|
||||||
# This is where the meta config is evaluated.
|
# This is where the meta config is evaluated.
|
||||||
eval = lib.evalModules {
|
eval = lib.evalModules {
|
||||||
modules = [
|
modules = lib.singleton metaConfig
|
||||||
metaConfig
|
|
||||||
./config/modules/meta/default.nix
|
|
||||||
] ++ (lib.attrValues hosts)
|
|
||||||
++ (lib.attrValues (removeAttrs argGen.targets ["common"]))
|
++ (lib.attrValues (removeAttrs argGen.targets ["common"]))
|
||||||
++ (lib.optional (builtins.pathExists ./config/trusted/meta.nix) ./config/trusted/meta.nix);
|
++ (lib.attrValues hosts)
|
||||||
|
++ (lib.optional (builtins.pathExists ./config/trusted/meta.nix) ./config/trusted/meta.nix)
|
||||||
|
++ lib.singleton ./config/modules/meta/default.nix;
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit sources;
|
inherit sources;
|
||||||
inherit (argGen) profiles users services;
|
inherit (argGen) profiles users services;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue