depot/cluster/lib/services.nix

20 lines
612 B
Nix
Raw Permalink Normal View History

2022-06-23 21:13:28 +03:00
{ config, lib, ... }:
with lib;
let
getHostConfigurations = svcConfig: hostName:
lib.mapAttrsToList (groupName: _: svcConfig.nixos.${groupName})
2022-10-17 15:38:55 +03:00
(lib.filterAttrs (_: lib.elem hostName) svcConfig.nodes);
2022-06-23 21:13:28 +03:00
getServiceConfigurations = svcConfig: getHostConfigurations svcConfig config.vars.hostName;
in
{
options.services = mkOption {
description = "Cluster services.";
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);
}