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"; + }; + }); }; };