refactor(matrix-synapse): get first listener port

This commit is contained in:
teutat3s 2024-01-27 11:19:30 +01:00
parent 2f75ae7e62
commit 3cfdd9d20a
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
2 changed files with 11 additions and 4 deletions

View file

@ -1,4 +1,8 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let
# Get port from first element in list of matrix-synapse listeners
synapsePort = "${toString (lib.findFirst (listener: listener.port != null) "" config.services.matrix-synapse.settings.listeners).port}";
in
{ {
systemd.services.matrix-appservice-irc.serviceConfig.SystemCallFilter = lib.mkForce [ systemd.services.matrix-appservice-irc.serviceConfig.SystemCallFilter = lib.mkForce [
"@system-service @pkey" "@system-service @pkey"
@ -13,7 +17,7 @@
settings = { settings = {
homeserver = { homeserver = {
domain = "pub.solar"; domain = "pub.solar";
url = "http://127.0.0.1:${toString (builtins.map (listener: listener.port) config.services.matrix-synapse.settings.listeners)}"; url = "http://127.0.0.1:${synapsePort}";
media_url = "https://matrix.pub.solar"; media_url = "https://matrix.pub.solar";
enablePresence = false; enablePresence = false;
}; };

View file

@ -1,5 +1,8 @@
{ config, flake, ... }: { config, flake, lib, ... }:
let
# Get port from first element in list of matrix-synapse listeners
synapsePort = "${toString (lib.findFirst (listener: listener.port != null) "" config.services.matrix-synapse.settings.listeners).port}";
in
{ {
age.secrets.nachtigall-metrics-nginx-basic-auth = { age.secrets.nachtigall-metrics-nginx-basic-auth = {
file = "${flake.self}/secrets/nachtigall-metrics-nginx-basic-auth.age"; file = "${flake.self}/secrets/nachtigall-metrics-nginx-basic-auth.age";
@ -15,7 +18,7 @@
proxyPass = "http://127.0.0.1:${toString(config.services.prometheus.exporters.node.port)}"; proxyPass = "http://127.0.0.1:${toString(config.services.prometheus.exporters.node.port)}";
}; };
locations."/_synapse/metrics" = { locations."/_synapse/metrics" = {
proxyPass = "http://127.0.0.1:${toString (builtins.map (listener: listener.port) config.services.matrix-synapse.settings.listeners)}"; proxyPass = "http://127.0.0.1:${synapsePort}";
}; };
}; };
}; };