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

68 lines
1.9 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,
...
}:
{
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 ];
verify.localCommands.paperless =
let
domain = "http://paperless.ingolf-wagner.de/accounts/login/?next=/";
curl = lib.getExe pkgs.curl;
grep = lib.getExe pkgs.gnugrep;
grepString = "paperless.chungus.private";
in
''
if ${curl} -s -o /dev/null -w "%{http_code}" ${domain} | ${grep} -q "200"; then
if ${curl} -s ${domain} | ${grep} -q "${grepString}"; then
echo "[ OK ] Die Seite hat Statuscode 200 und enthält den String '${grepString}'."
else
echo "[Fail] Der Statuscode ist 200, aber die Seite enthält den String '${grepString}' nicht."
fi
else
echo "[Fail] Die Seite hat keinen Statuscode 200."
fi
'';
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;
};
};
}