Skip to content

Commit 71ec941

Browse files
authored
nixos/services.paperless: add extra files OCR (#396946)
2 parents a0844d7 + 88e40e4 commit 71ec941

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

nixos/modules/services/misc/paperless.nix

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,14 @@ in
358358
description = "Settings to pass to the document exporter as CLI arguments.";
359359
};
360360
};
361+
362+
configureTika = lib.mkOption {
363+
type = lib.types.bool;
364+
default = false;
365+
description = ''
366+
Whether to configure Tika and Gotenberg to process Office and e-mail files with OCR.
367+
'';
368+
};
361369
};
362370

363371
config = lib.mkIf cfg.enable (
@@ -378,12 +386,18 @@ in
378386
];
379387
};
380388

381-
services.paperless.settings = lib.mkIf cfg.database.createLocally {
382-
PAPERLESS_DBENGINE = "postgresql";
383-
PAPERLESS_DBHOST = "/run/postgresql";
384-
PAPERLESS_DBNAME = "paperless";
385-
PAPERLESS_DBUSER = "paperless";
386-
};
389+
services.paperless.settings = lib.mkMerge [
390+
(lib.mkIf cfg.database.createLocally {
391+
PAPERLESS_DBENGINE = "postgresql";
392+
PAPERLESS_DBHOST = "/run/postgresql";
393+
PAPERLESS_DBNAME = "paperless";
394+
PAPERLESS_DBUSER = "paperless";
395+
})
396+
(lib.mkIf cfg.configureTika {
397+
PAPERLESS_GOTENBERG_ENABLED = true;
398+
PAPERLESS_TIKA_ENABLED = true;
399+
})
400+
];
387401

388402
systemd.slices.system-paperless = {
389403
description = "Paperless Document Management System Slice";
@@ -571,6 +585,18 @@ in
571585
gid = config.ids.gids.paperless;
572586
};
573587
};
588+
589+
services.gotenberg = lib.mkIf cfg.configureTika {
590+
enable = true;
591+
# https://github.com/paperless-ngx/paperless-ngx/blob/v2.15.3/docker/compose/docker-compose.sqlite-tika.yml#L64-L69
592+
chromium.disableJavascript = true;
593+
extraArgs = [ "--chromium-allow-list=file:///tmp/.*" ];
594+
};
595+
596+
services.tika = lib.mkIf cfg.configureTika {
597+
enable = true;
598+
enableOcr = true;
599+
};
574600
}
575601

576602
(lib.mkIf cfg.exporter.enable {

0 commit comments

Comments
 (0)