2024-01-10 04:11:11 +00:00
|
|
|
# Paperless-ngx is a document scanning and management solution.
|
|
|
|
|
2024-04-20 13:42:06 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
{
|
2023-11-10 03:37:34 +00:00
|
|
|
|
|
|
|
config = lib.mkIf config.services.paperless.enable {
|
|
|
|
|
|
|
|
services.paperless = {
|
|
|
|
mediaDir = "/data/generic/paperless";
|
|
|
|
passwordFile = config.secrets.paperless.dest;
|
2024-01-15 17:49:31 +00:00
|
|
|
settings = {
|
2024-04-20 13:42:06 +00:00
|
|
|
PAPERLESS_OCR_USER_ARGS = builtins.toJSON { invalidate_digital_signatures = true; };
|
2023-11-10 03:37:34 +00:00
|
|
|
|
|
|
|
# Enable if changing the path name in Caddy
|
|
|
|
# PAPERLESS_FORCE_SCRIPT_NAME = "/paperless";
|
|
|
|
# PAPERLESS_STATIC_URL = "/paperless/static/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-21 02:13:10 +00:00
|
|
|
# Allow Nextcloud and user to see files
|
2024-04-20 13:42:06 +00:00
|
|
|
users.users.nextcloud.extraGroups = lib.mkIf config.services.nextcloud.enable [ "paperless" ];
|
2024-01-21 02:13:10 +00:00
|
|
|
users.users.${config.user}.extraGroups = [ "paperless" ];
|
2023-11-10 03:37:34 +00:00
|
|
|
|
2024-04-20 13:42:06 +00:00
|
|
|
caddy.routes = [
|
|
|
|
{
|
|
|
|
match = [
|
|
|
|
{
|
|
|
|
host = [ config.hostnames.paperless ];
|
|
|
|
# path = [ "/paperless*" ]; # Change path name in Caddy
|
|
|
|
}
|
|
|
|
];
|
|
|
|
handle = [
|
|
|
|
{
|
|
|
|
handler = "reverse_proxy";
|
|
|
|
upstreams = [ { dial = "localhost:${builtins.toString config.services.paperless.port}"; } ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2023-11-10 03:37:34 +00:00
|
|
|
|
2024-03-30 15:41:18 +00:00
|
|
|
# Configure Cloudflare DNS to point to this machine
|
|
|
|
services.cloudflare-dyndns.domains = [ config.hostnames.paperless ];
|
|
|
|
|
2023-11-10 03:37:34 +00:00
|
|
|
secrets.paperless = {
|
|
|
|
source = ../../../private/prometheus.age;
|
|
|
|
dest = "${config.secretsDirectory}/paperless";
|
|
|
|
owner = "paperless";
|
|
|
|
group = "paperless";
|
|
|
|
permissions = "0440";
|
|
|
|
};
|
|
|
|
systemd.services.paperless-secret = {
|
|
|
|
requiredBy = [ "paperless.service" ];
|
|
|
|
before = [ "paperless.service" ];
|
|
|
|
};
|
|
|
|
|
2024-01-21 03:19:19 +00:00
|
|
|
# Fix paperless shared permissions
|
2024-02-10 01:40:04 +00:00
|
|
|
systemd.services.paperless-web.serviceConfig.UMask = lib.mkForce "0026";
|
2024-04-20 13:42:06 +00:00
|
|
|
systemd.services.paperless-scheduler.serviceConfig.UMask = lib.mkForce "0026";
|
|
|
|
systemd.services.paperless-task-queue.serviceConfig.UMask = lib.mkForce "0026";
|
2023-11-10 03:37:34 +00:00
|
|
|
};
|
|
|
|
}
|