{ config, ... }:
let
  stDomain = "${config.clan.core.vars.generators.b4l-stirling-pdf.files.subdomain.value}.${config.networking.fqdn}";
in
{
  clan.core.vars.generators.b4l-stirling-pdf = {
    files.subdomain.secret = false;

    prompts = {
      subdomain = {
        persist = true;
        type = "line";
        description = "Sub-domain for Stirling PDF app. Default:(pdf)";
      };
    };
    script = ''cat $prompts/subdomain || echo -n "pdf" > $out/subdomain'';
  };

  services.nginx.virtualHosts."${stDomain}" = {
    forceSSL = true;
    useACMEHost = "${config.networking.fqdn}";
    locations."/" = {
      proxyPass = "http://localhost:${builtins.toString config.services.stirling-pdf.environment.SERVER_PORT}";
    };
  };
}
