nixos-config/machines/chungus/service-paperless.nix

86 lines
2.5 KiB
Nix
Raw Normal View History

2024-08-29 03:26:04 +02:00
{
config,
pkgs,
lib,
2024-08-29 03:26:04 +02:00
nixos-artwork,
factsGenerator,
2024-08-29 03:26:04 +02:00
...
}:
{
2024-03-06 13:22:22 +01:00
2024-03-04 19:05:30 +01:00
services.paperless = {
enable = true;
2024-03-09 16:50:33 +01:00
address = "0.0.0.0";
2024-05-27 19:10:54 +02:00
settings = {
2024-03-18 21:00:48 +01:00
PAPERLESS_OCR_LANGUAGE = "deu+eng";
PAPERLESS_APP_TITLE = "paperless.chungus.private";
2024-08-29 03:26:04 +02:00
PAPERLESS_CONSUMER_IGNORE_PATTERN = builtins.toJSON [
".DS_STORE/*"
"desktop.ini"
];
PAPERLESS_EMAIL_TASK_CRON = "0 */8 * * *"; # “At minute 0 past every 8th hour.”
2024-05-22 20:54:36 +02:00
#PAPERLESS_CONSUMER_DELETE_DUPLICATES = false;
2024-03-18 21:00:48 +01:00
};
2024-03-04 19:05:30 +01:00
};
2024-03-06 13:22:22 +01:00
2024-05-12 09:32:04 +02:00
services.permown."/var/lib/paperless/consume" = {
owner = "paperless";
group = "paperless";
directory-mode = "755";
file-mode = "640";
};
2024-03-06 13:22:22 +01:00
networking.firewall.interfaces.wg0.allowedTCPPorts = [ config.services.paperless.port ];
healthchecks.http.paperless = {
2024-09-16 02:06:03 +02:00
url = "http://paperless.ingolf-wagner.de/accounts/login/?next=/";
expectedContent = "paperless.chungus.private";
};
2024-03-06 13:22:22 +01:00
2024-03-04 19:05:30 +01:00
services.nginx.virtualHosts."paperless.${config.networking.hostName}.private" = {
2024-05-22 09:28:11 +02:00
serverAliases = [ "paperless.ingolf-wagner.de" ];
2024-03-04 19:05:30 +01:00
extraConfig = ''
allow ${config.tinc.private.subnet};
2024-05-22 09:28:11 +02:00
allow ${config.wireguard.wg0.subnet};
2024-03-04 19:05:30 +01:00
deny all;
'';
locations."/" = {
2024-05-12 09:32:04 +02:00
extraConfig = ''
client_max_body_size 500M;
'';
2024-03-04 19:05:30 +01:00
proxyPass = "http://localhost:${toString config.services.paperless.port}";
proxyWebsockets = true;
};
};
clan.core.facts.services."paperless-ngx.borg" = factsGenerator.password { name = "borgbackup"; };
clan.core.facts.services."paperless-ngx.ssh" = factsGenerator.ssh { name = "paperless-ngx"; };
# backup
services.borgbackup.jobs."paperless-ngx" = {
paths = [ config.services.paperless.dataDir ];
2024-10-06 11:15:45 +02:00
repo = "root@orbi.bear:borg-${config.networking.hostName}-paperless";
compression = "auto,lzma";
startAt = "daily";
encryption = {
2024-10-06 11:15:45 +02:00
mode = "keyfile-blake2";
passCommand = "cat ${
toString config.clan.core.facts.services."paperless-ngx.borg".secret."password.borgbackup".path
}";
};
environment = {
BORG_RSH = "ssh -i ${
toString
config.clan.core.facts.services."paperless-ngx.ssh".secret."ssh.paperless-ngx.id_ed25519".path
}";
BORG_RELOCATED_REPO_ACCESS_IS_OK = "yes";
};
prune.keep = {
2024-10-06 11:17:42 +02:00
within = "3d"; # Keep all backups in the last 10 days.
weekly = 2; # Keep 8 additional end of week archives.
monthly = -1; # Keep end of month archive for every month
};
doInit = true;
};
2024-03-04 19:05:30 +01:00
}