{ pkgs, ... }:
{
  services.nginx = {
    virtualHosts."sonarr.donsz.nl" = {
      forceSSL = true;
      http2 = true;
      enableACME = true;

      locations."/" = {
        proxyPass = "http://[::1]:8989";
      };
    };
  };
  services.oauth2-proxy.nginx.virtualHosts."sonarr.donsz.nl" = {
    allowed_groups = [ "torrent" ];
  };

  services.sonarr = {
    enable = true;
    group = "jellyfin";
    user = "jellyfin";

    environmentFiles = [
      (pkgs.writeText "env" ''
        SONARR__AUTH__METHOD="External"
      '')
    ];
  };
}
