{ config, pkgs, lib, mkDomain, ... }:
{
  # paperless-ngx
  # A supercharged version of paperless: scan, index, and archive all of your physical documents

  services.paperless = {
    enable = true;
    #package = pkgs.paperless-ngx;
    #port = 28981;
    #address = "localhost";
    #passwordfile = null; # file contining the superuser 'admin' password, optionally set with `${datadir}/paperless-manage createsuperuser`
    #datadir = "/var/lib/paperless";
    #mediadir = "${datadir}/media";
    #consumptiondir = "${datadir}/consume"; # Directory from which new documents are imported. (TODO: zotero)
    #extraconfig = {};
    #consumptiondirispublic = false; # Whether all users can write to the consumption dir
  };
  services.nginx.virtualHosts.${mkDomain "paperless"} = lib.mkIf config.services.paperless.enable {
    forceSSL = true; # addSSL = true;
    enableACME = true; #useACMEHost = acmeDomain;
    locations."/" = {
      proxyPass = "http://127.0.0.1:${toString config.services.paperless.port}";
      proxyWebsockets = true;
    };
  };
}
