2022-06-23 21:13:28 +03:00
|
|
|
{ config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
getHostConfigurations = svcConfig: hostName:
|
|
|
|
lib.mapAttrsToList (groupName: _: svcConfig.nixos.${groupName})
|
|
|
|
(lib.filterAttrs (_: v: lib.elem hostName v) svcConfig.nodes);
|
|
|
|
|
|
|
|
getServiceConfigurations = svcConfig: getHostConfigurations svcConfig config.vars.hostName;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services = mkOption {
|
|
|
|
description = "Cluster services.";
|
2022-08-03 23:53:14 +03:00
|
|
|
type = with types; attrsOf (submodule (import ./service-module.nix config.vars));
|
2022-06-23 21:13:28 +03:00
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
config.out.injectedNixosConfig = lib.flatten (lib.mapAttrsToList (_: getServiceConfigurations) config.services);
|
|
|
|
}
|