From cefa63892dbee89414b0ffae314593ba37e2fb0b Mon Sep 17 00:00:00 2001 From: niten Date: Tue, 30 Jan 2024 14:21:27 -0800 Subject: [PATCH] Allow for smtp == imap servers --- mail-server.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mail-server.nix b/mail-server.nix index 71b32f4..589ef35 100644 --- a/mail-server.nix +++ b/mail-server.nix @@ -201,14 +201,13 @@ in { config = mkIf cfg.enable { services = { nginx = { - virtualHosts = { - "${cfg.smtp.hostname}".locations."/metrics" = { - proxyPass = "http://localhost:${toString metricsPort}/metrics"; - }; - "${cfg.imap.hostname}".locations."/metrics" = { - proxyPass = "http://localhost:${toString metricsPort}/metrics"; - }; - }; + virtualHosts = + let mailHostnames = unique [ cfg.smtp.hostname cfg.imap.hostname ]; + in genAttrs mailHostnames (hostname: { + "${hostname}".locations."/metrics" = { + proxyPass = "http://localhost:${toString metricsPort}/metrics"; + }; + }); }; };