From 3cfdd9d20aa554893b27d8173b1a50e0d2a10b48 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sat, 27 Jan 2024 11:19:30 +0100 Subject: [PATCH] refactor(matrix-synapse): get first listener port --- hosts/nachtigall/apps/matrix/irc.nix | 6 +++++- hosts/nachtigall/apps/nginx-prometheus-exporters.nix | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hosts/nachtigall/apps/matrix/irc.nix b/hosts/nachtigall/apps/matrix/irc.nix index 50e566c..3b40664 100644 --- a/hosts/nachtigall/apps/matrix/irc.nix +++ b/hosts/nachtigall/apps/matrix/irc.nix @@ -1,4 +1,8 @@ { 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 [ "@system-service @pkey" @@ -13,7 +17,7 @@ settings = { homeserver = { 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"; enablePresence = false; }; diff --git a/hosts/nachtigall/apps/nginx-prometheus-exporters.nix b/hosts/nachtigall/apps/nginx-prometheus-exporters.nix index 358f9fe..e1f8e30 100644 --- a/hosts/nachtigall/apps/nginx-prometheus-exporters.nix +++ b/hosts/nachtigall/apps/nginx-prometheus-exporters.nix @@ -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 = { 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)}"; }; 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}"; }; }; };