{ lib, ... }:

let
  domain = "htlid.giugl.io";
  network = import ./network.nix;
  auth_block = (import ./openid.nix { inherit lib; }).openresty_oidc_block;
in
{
  services = {
    lidarr = {
      enable = true;
      group = "media";
    };

    nginx.virtualHosts.${domain} = {
      forceSSL = true;
      enableACME = true;
      locations."/" = {
        proxyPass = "http://127.0.0.1:8686";
        extraConfig = auth_block {
          access_role = "lidarr";
        };
      };
    };
  };

  networking.extraHosts = ''
    ${network.architect-lan} ${domain}
    ${network.architect-wg} ${domain}
    ${network.architect-ts} ${domain}
  '';

  users.groups.media.members = [ "lidarr" ];
}