67 lines
1.9 KiB
Nix
67 lines
1.9 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
nixos-artwork,
|
|
...
|
|
}:
|
|
{
|
|
|
|
services.paperless = {
|
|
enable = true;
|
|
address = "0.0.0.0";
|
|
settings = {
|
|
PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
|
PAPERLESS_APP_TITLE = "paperless.chungus.private";
|
|
PAPERLESS_CONSUMER_IGNORE_PATTERN = builtins.toJSON [
|
|
".DS_STORE/*"
|
|
"desktop.ini"
|
|
];
|
|
PAPERLESS_EMAIL_TASK_CRON = "0 */8 * * *"; # “At minute 0 past every 8th hour.”
|
|
#PAPERLESS_CONSUMER_DELETE_DUPLICATES = false;
|
|
};
|
|
};
|
|
|
|
services.permown."/var/lib/paperless/consume" = {
|
|
owner = "paperless";
|
|
group = "paperless";
|
|
directory-mode = "755";
|
|
file-mode = "640";
|
|
};
|
|
|
|
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
|
|
'';
|
|
|
|
services.nginx.virtualHosts."paperless.${config.networking.hostName}.private" = {
|
|
serverAliases = [ "paperless.ingolf-wagner.de" ];
|
|
extraConfig = ''
|
|
allow ${config.tinc.private.subnet};
|
|
allow ${config.wireguard.wg0.subnet};
|
|
deny all;
|
|
'';
|
|
locations."/" = {
|
|
extraConfig = ''
|
|
client_max_body_size 500M;
|
|
'';
|
|
proxyPass = "http://localhost:${toString config.services.paperless.port}";
|
|
proxyWebsockets = true;
|
|
};
|
|
};
|
|
}
|