{ config, lib, libNginx, ... }: with lib; let cfg = config.nixfiles.modules.sonarr; in { options.nixfiles.modules.sonarr = { enable = mkEnableOption "Sonarr"; domain = mkOption { description = "Domain name sans protocol scheme."; type = with types; str; default = "sonarr.${config.networking.domain}"; }; }; config = mkIf cfg.enable { ark.directories = [ "/var/lib/sonarr" ]; nixfiles.modules.nginx = { enable = true; upstreams.sonarr.servers."127.0.0.1:8989" = { }; virtualHosts.${cfg.domain} = { locations."/".proxyPass = "http://sonarr"; extraConfig = libNginx.config.internalOnly; }; }; services.sonarr = { enable = true; user = "rtorrent"; group = "rtorrent"; }; }; }