{ config, lib, libNginx, ... }: let cfg = config.nixfiles.modules.thelounge; in { options.nixfiles.modules.thelounge = { enable = lib.mkEnableOption "The Lounge"; port = lib.mkOption { description = "Port."; type = lib.types.port; default = 11887; }; domain = lib.mkOption { description = "Domain name sans protocol scheme."; type = lib.types.str; default = "irc.${config.networking.domain}"; }; }; config = lib.mkIf cfg.enable { ark.directories = [ "/var/lib/thelounge" ]; nixfiles.modules.nginx = { upstreams.thelounge.servers."127.0.0.1:${toString cfg.port}" = { }; virtualHosts.${cfg.domain} = { locations."/".proxyPass = "http://thelounge"; extraConfig = libNginx.config.internalOnly; }; }; services.thelounge = { enable = true; extraConfig = { public = false; host = "127.0.0.1"; inherit (cfg) port; reverseProxy = true; defaults = { }; }; }; }; }