Commit 88e40e42 authored by flakeuser's avatar flakeuser
Browse files

nixos/services.paperless: add extra files OCR

This adds a setting for processing extra files with OCR through tika and
gotenberg
parent ff0d4681
Loading
Loading
Loading
Loading
+32 −6
Original line number Diff line number Diff line
@@ -357,6 +357,14 @@ in
        description = "Settings to pass to the document exporter as CLI arguments.";
      };
    };

    configureTika = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = ''
        Whether to configure Tika and Gotenberg to process Office and e-mail files with OCR.
      '';
    };
  };

  config = lib.mkIf cfg.enable (
@@ -377,12 +385,18 @@ in
          ];
        };

        services.paperless.settings = lib.mkIf cfg.database.createLocally {
        services.paperless.settings = lib.mkMerge [
          (lib.mkIf cfg.database.createLocally {
            PAPERLESS_DBENGINE = "postgresql";
            PAPERLESS_DBHOST = "/run/postgresql";
            PAPERLESS_DBNAME = "paperless";
            PAPERLESS_DBUSER = "paperless";
        };
          })
          (lib.mkIf cfg.configureTika {
            PAPERLESS_GOTENBERG_ENABLED = true;
            PAPERLESS_TIKA_ENABLED = true;
          })
        ];

        systemd.slices.system-paperless = {
          description = "Paperless Document Management System Slice";
@@ -571,6 +585,18 @@ in
            gid = config.ids.gids.paperless;
          };
        };

        services.gotenberg = lib.mkIf cfg.configureTika {
          enable = true;
          # https://github.com/paperless-ngx/paperless-ngx/blob/v2.15.3/docker/compose/docker-compose.sqlite-tika.yml#L64-L69
          chromium.disableJavascript = true;
          extraArgs = [ "--chromium-allow-list=file:///tmp/.*" ];
        };

        services.tika = lib.mkIf cfg.configureTika {
          enable = true;
          enableOcr = true;
        };
      }

      (lib.mkIf cfg.exporter.enable {