cluster/lib: add otherNodes in services

This commit is contained in:
Max Headroom 2022-08-03 22:53:14 +02:00
parent acd4e1a09d
commit e2da732613
2 changed files with 14 additions and 1 deletions

View file

@ -1,6 +1,13 @@
vars:
{ name, config, lib, ... }:
with lib;
let
notSelf = x: x != vars.hostName;
filterGroup = builtins.filter notSelf;
in
{
options = {
nodes = mkOption {
@ -17,10 +24,16 @@ with lib;
type = with types; attrsOf (oneOf [ str (listOf str) ]);
default = [];
};
otherNodes = mkOption {
description = "Other nodes in the group.";
type = with types; attrsOf (listOf str);
default = [];
};
nixos = mkOption {
description = "NixOS configurations per node group.";
type = with types; attrs;
default = {};
};
};
config.otherNodes = builtins.mapAttrs (_: filterGroup) config.nodes;
}

View file

@ -12,7 +12,7 @@ in
{
options.services = mkOption {
description = "Cluster services.";
type = with types; attrsOf (submodule (import ./service-module.nix ));
type = with types; attrsOf (submodule (import ./service-module.nix config.vars));
default = {};
};
config.out.injectedNixosConfig = lib.flatten (lib.mapAttrsToList (_: getServiceConfigurations) config.services);