small cleanup

This commit is contained in:
Daniel Lovbrotte Olsen 2022-10-10 12:59:11 +02:00
parent ccbd092679
commit 74a4cd25d1
1 changed files with 15 additions and 16 deletions

View File

@ -7,11 +7,6 @@ let
pluginsEnv = cfg.package.python.buildEnv.override { pluginsEnv = cfg.package.python.buildEnv.override {
extraLibs = cfg.plugins; extraLibs = cfg.plugins;
}; };
typeToResources = t: {
"fed-receiver" = [ "federation" ];
"fed-sender" = [ ];
}.t;
in in
{ {
options.services.matrix-synapse-next = { options.services.matrix-synapse-next = {
@ -130,6 +125,11 @@ in
defaultApp = if (instanceCfg.autoType == null) defaultApp = if (instanceCfg.autoType == null)
then "synapse.app.generic_worker" then "synapse.app.generic_worker"
else mapTypeApp instanceCfg.autoType; else mapTypeApp instanceCfg.autoType;
typeToResources = t: {
"fed-receiver" = [ "federation" ];
"fed-sender" = [ ];
}.${t};
in lib.mkOption { in lib.mkOption {
type = lib.types.submodule ({config, ...}: { type = lib.types.submodule ({config, ...}: {
freeformType = format.type; freeformType = format.type;
@ -190,6 +190,7 @@ in
options.names = lib.mkOption { options.names = lib.mkOption {
type = lib.types.listOf (lib.types.enum [ "client" "consent" "federation" "keys" "media" "metrics" "openid" "replication" "static" "webclient" ]); type = lib.types.listOf (lib.types.enum [ "client" "consent" "federation" "keys" "media" "metrics" "openid" "replication" "static" "webclient" ]);
description = "A list of resources to host on this port"; description = "A list of resources to host on this port";
default = lib.optionals isAuto (typeToResources instanceCfg.autoType);
}; };
options.compress = lib.mkOption { options.compress = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
@ -197,6 +198,7 @@ in
default = false; default = false;
}; };
}); });
default = [{ }];
}; };
}); });
description = "Listener configuration for the worker, similar to the main synapse listener"; description = "Listener configuration for the worker, similar to the main synapse listener";
@ -517,17 +519,14 @@ in
}) })
({ ({
services.matrix-synapse-next.workers.instances = lib.mapAttrs' services.matrix-synapse-next.workers.instances = let
(name: value: lib.attrsets.nameValuePair "auto-fed-receiver${name}" value) genAttrs' = items: f: g: builtins.listToAttrs (builtins.map (n: lib.attrsets.nameValuePair (f n) (g n)) items);
(lib.genAttrs (lib.genList (x: builtins.toString x) cfg.workers.federationReceivers) in genAttrs' (lib.genList (x: x) cfg.workers.federationReceivers)
(x: "auto-fed-receiver${builtins.toString x}")
(x: { (x: {
autoType = "fed-receiver"; autoType = "fed-receiver";
settings.worker_listeners = [ settings.worker_listeners = [{ port = cfg.workers.workerStartingPort + x; }];
{ port = cfg.workers.workerStartingPort + (lib.strings.toInt x); });
resources = [ {names = ["federation"];} ];
}
];
}));
}) })
]) ])