diff --git a/hosts/cox/paperless.nix b/hosts/cox/paperless.nix index 7e3fd9dc..e9418130 100644 --- a/hosts/cox/paperless.nix +++ b/hosts/cox/paperless.nix @@ -6,6 +6,8 @@ pub-solar.paperless = { enable = true; hostStateDir = "/opt/documents/paperless"; + domain = "cox.lan"; + path = "/paperless"; ftp = { enable = true; diff --git a/modules/paperless/container.nix b/modules/paperless/container.nix index 00775064..61b27b03 100644 --- a/modules/paperless/container.nix +++ b/modules/paperless/container.nix @@ -35,11 +35,16 @@ in { consumptionDirIsPublic = true; port = 8899; extraConfig = { + PAPERLESS_FORCE_SCRIPT_NAME = "${cfg.path}"; PAPERLESS_OCR_LANGUAGE = "deu+eng"; PAPERLESS_ALLOWED_HOSTS = "${cfg.domain}"; PAPERLESS_CSRF_TRUSTED_ORIGINS = "http://${cfg.domain}"; PAPERLESS_CORS_ALLOWED_HOSTS = "http://${cfg.domain}"; - PAPERLESS_FILENAME_FORMAT = "{correspondent}/{created_year}/{asn}_{title}"; + PAPERLESS_FILENAME_FORMAT = "{created_year}/{correspondent}/{created_month}_{created_day}_{title}"; + PAPERLESS_TASK_WORKERS=2; + PAPERLESS_CONSUMER_INOTIFY_DELAY=5; + PAPERLESS_CONSUMER_RECURSIVE=1; + PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS=1; }; }; diff --git a/modules/paperless/default.nix b/modules/paperless/default.nix index 229db527..ca1083ee 100644 --- a/modules/paperless/default.nix +++ b/modules/paperless/default.nix @@ -7,7 +7,10 @@ with lib; let psCfg = config.pub-solar; cfg = config.pub-solar.paperless; in { - imports = [./container.nix]; + imports = [ + ./container.nix + ./nginx.nix + ]; options.pub-solar.paperless = { enable = mkEnableOption {default = false;}; @@ -18,6 +21,12 @@ in { default = "paperless.local"; }; + path = mkOption { + type = types.str; + description = "Sets the path to listen on. Use empty string to listen on root."; + default = ""; + }; + hostStateDir = mkOption { type = types.str; default = "/var/lib/paperless-container"; @@ -66,19 +75,5 @@ in { ]; }; - services.nginx = { - enable = true; - virtualHosts."${cfg.domain}" = { - locations."/" = { - proxyPass = "http://127.0.0.1:8899"; - proxyWebsockets = true; - extraConfig = '' - proxy_read_timeout 300s; - proxy_set_header Host ''$host; - proxy_set_header X-Forwarded-For ''$remote_addr; - ''; - }; - }; - }; }; } diff --git a/modules/paperless/nginx.nix b/modules/paperless/nginx.nix new file mode 100644 index 00000000..1ab8a7cf --- /dev/null +++ b/modules/paperless/nginx.nix @@ -0,0 +1,22 @@ +{ config, ... }: + +let + cfg = config.pub-solar.paperless; + nginxLocation = if cfg.path == "" then "/" else cfg.path; +in +{ + services.nginx = { + enable = true; + virtualHosts."${cfg.domain}" = { + locations."${nginxLocation}" = { + proxyPass = "http://127.0.0.1:8899"; + proxyWebsockets = true; + extraConfig = '' + proxy_read_timeout 300s; + proxy_set_header Host ${cfg.domain}; + proxy_set_header X-Forwarded-For ''$remote_addr; + ''; + }; + }; + }; +}