depot/cluster/lib/service-module.nix

72 lines
1.9 KiB
Nix
Raw Permalink Normal View History

2024-07-04 05:06:20 +03:00
{ config, lib, name, ... }:
2022-06-23 21:13:28 +03:00
with lib;
let
2023-08-31 01:55:45 +03:00
filterGroup = group: hostName: builtins.filter (x: x != hostName) group;
2024-07-04 05:06:20 +03:00
serviceName = name;
in
2022-06-23 21:13:28 +03:00
{
2024-07-07 00:43:02 +03:00
imports = [
./services/secrets.nix
];
2022-06-23 21:13:28 +03:00
options = {
nodes = mkOption {
description = ''
Groups of worker machines to run this service on.
Allows for arbitrary multi-node constructs, such as:
* 1 master, N workers
* N masters, M workers
* N nodes
* 1 node
* X evaluators, Y smallBuilders, Z bigBuilders
etc.
'';
2024-07-17 20:34:59 +03:00
type = with types; lazyAttrsOf (oneOf [ str (listOf str) ]);
2022-06-23 21:13:28 +03:00
default = [];
};
otherNodes = mkOption {
description = "Other nodes in the group.";
2024-07-17 20:34:59 +03:00
type = with types; lazyAttrsOf (functionTo (listOf str));
default = [];
};
2022-06-23 21:13:28 +03:00
nixos = mkOption {
description = "NixOS configurations per node group.";
type = with types; attrs;
default = {};
};
2024-07-04 05:06:20 +03:00
meshLinks = mkOption {
description = "Create host links on the mesh network.";
2024-08-23 02:06:38 +03:00
type = types.attrsOf (types.attrsOf (types.submodule {
2024-07-04 05:06:20 +03:00
options = {
link = mkOption {
type = types.deferredModule;
default = {};
};
};
}));
default = {};
};
simulacrum = {
enable = mkEnableOption "testing this service in the Simulacrum";
deps = mkOption {
description = "Other services to include.";
type = with types; listOf str;
default = [];
};
settings = mkOption {
description = "NixOS test configuration.";
type = types.deferredModule;
default = {};
};
augments = mkOption {
description = "Cluster augments (will be propagated).";
type = types.deferredModule;
default = {};
};
};
2022-06-23 21:13:28 +03:00
};
2023-08-31 01:55:45 +03:00
config.otherNodes = builtins.mapAttrs (const filterGroup) config.nodes;
2022-06-23 21:13:28 +03:00
}