2024-07-04 05:06:20 +03:00
|
|
|
{ config, lib, name, ... }:
|
2022-06-23 21:13:28 +03:00
|
|
|
with lib;
|
|
|
|
|
2022-08-03 23:53:14 +03:00
|
|
|
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;
|
2022-08-03 23:53:14 +03:00
|
|
|
in
|
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
type = with types; attrsOf (oneOf [ str (listOf str) ]);
|
|
|
|
default = [];
|
|
|
|
};
|
2022-08-03 23:53:14 +03:00
|
|
|
otherNodes = mkOption {
|
|
|
|
description = "Other nodes in the group.";
|
2023-08-31 01:55:45 +03:00
|
|
|
type = with types; attrsOf (functionTo (listOf str));
|
2022-08-03 23:53:14 +03:00
|
|
|
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.";
|
|
|
|
type = types.attrsOf (types.submodule ({ name, ... }: {
|
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${serviceName}-${name}";
|
|
|
|
};
|
|
|
|
link = mkOption {
|
|
|
|
type = types.deferredModule;
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
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
|
|
|
}
|