2021-07-12 19:07:39 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.my.services.paperless;
|
|
|
|
my = config.my;
|
|
|
|
domain = config.networking.domain;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.paperless = {
|
|
|
|
enable = lib.mkEnableOption "Paperless";
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 8080;
|
|
|
|
example = 8080;
|
|
|
|
description = "Internal port for Paperless service";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-13 13:15:38 +02:00
|
|
|
# HACK: see https://github.com/NixOS/nixpkgs/issues/111852
|
|
|
|
networking.firewall.extraCommands = ''
|
|
|
|
iptables -N DOCKER-USER || true
|
|
|
|
iptables -F DOCKER-USER
|
|
|
|
iptables -A DOCKER-USER -i eno1 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
|
|
iptables -A DOCKER-USER -i eno1 -j DROP
|
|
|
|
'';
|
|
|
|
|
2021-07-12 19:07:39 +02:00
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
"paperless.${domain}" = {
|
|
|
|
forceSSL = true;
|
2021-07-13 00:57:33 +02:00
|
|
|
useACMEHost = domain;
|
2021-07-12 19:07:39 +02:00
|
|
|
|
2021-07-13 01:14:01 +02:00
|
|
|
listen = [
|
|
|
|
# FIXME: hardcoded tailscale IP
|
|
|
|
{
|
|
|
|
addr = "100.80.61.67";
|
|
|
|
port = 443;
|
|
|
|
ssl = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
addr = "100.80.61.67";
|
|
|
|
port = 80;
|
|
|
|
ssl = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2021-07-12 19:07:39 +02:00
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-07-13 22:20:21 +02:00
|
|
|
|
|
|
|
my.services.borg-backup = mkIf cfg.enable {
|
2021-07-14 03:00:36 +02:00
|
|
|
paths = [
|
|
|
|
"/var/lib/docker/volumes/paperless_data"
|
|
|
|
"/var/lib/docker/volumes/paperless_media"
|
|
|
|
"/var/lib/docker/volumes/paperless_pgdata"
|
|
|
|
];
|
2021-07-13 22:20:21 +02:00
|
|
|
};
|
2021-07-12 19:07:39 +02:00
|
|
|
};
|
|
|
|
}
|