depot/cluster/lib/services.nix

27 lines
647 B
Nix
Raw Normal View History

2022-06-23 21:13:28 +03:00
{ config, lib, ... }:
with lib;
let
2023-08-31 01:55:45 +03:00
getHostConfigurations = hostName: svcConfig:
2022-06-23 21:13:28 +03:00
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
2023-08-31 01:55:45 +03:00
introspectionModule._module.args.cluster = {
inherit (config) vars;
inherit config;
};
2022-06-23 21:13:28 +03:00
in
{
options.services = mkOption {
description = "Cluster services.";
2023-08-31 01:55:45 +03:00
type = with types; attrsOf (submodule ./service-module.nix);
2022-06-23 21:13:28 +03:00
default = {};
};
2023-08-31 01:55:45 +03:00
config.out.injectNixosConfig = hostName: (lib.flatten (lib.mapAttrsToList (_: getHostConfigurations hostName) config.services)) ++ [
introspectionModule
];
2022-06-23 21:13:28 +03:00
}