{ lib, config, proxyReverse, setup, ... }: let cfg = config.my.servers.sonarr; in { options.my.servers.sonarr = setup.mkOptions "sonarr" "series" 8989; config = { networking.firewall.allowedTCPPorts = lib.mkIf (!cfg.isLocal) [ cfg.port ]; services = { sonarr = lib.mkIf cfg.enable { enable = true; group = "piracy"; }; nginx.virtualHosts."${cfg.host}" = lib.mkIf cfg.enableProxy ( proxyReverse cfg.hostName cfg.port // { } ); }; }; }