2023-01-28 21:27:52 +00:00
|
|
|
{
|
2023-10-07 14:45:42 +00:00
|
|
|
flake,
|
2023-01-28 21:27:52 +00:00
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2022-02-14 09:49:49 +00:00
|
|
|
psCfg = config.pub-solar;
|
|
|
|
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
|
2023-08-29 11:56:18 +00:00
|
|
|
|
2023-10-07 14:45:42 +00:00
|
|
|
dataDir = "${xdg.dataHome}/Paperless";
|
2023-10-09 20:52:28 +00:00
|
|
|
backupDir = "${xdg.dataHome}/PaperlessBackup";
|
2023-10-07 14:45:42 +00:00
|
|
|
consumptionDir = "/home/${psCfg.user.name}/.local/share/scandir";
|
|
|
|
in {
|
|
|
|
services.paperless = {
|
|
|
|
enable = true;
|
|
|
|
user = psCfg.user.name;
|
|
|
|
consumptionDir = consumptionDir;
|
|
|
|
dataDir = dataDir;
|
2023-11-01 15:27:29 +00:00
|
|
|
address = "127.0.0.1";
|
2023-10-07 14:45:42 +00:00
|
|
|
extraConfig = {
|
|
|
|
PAPERLESS_OCR_LANGUAGE = "nld+deu";
|
|
|
|
PAPERLESS_ADMIN_USER = psCfg.user.name;
|
|
|
|
PAPERLESS_AUTO_LOGIN_USERNAME = psCfg.user.name;
|
2023-11-01 15:27:29 +00:00
|
|
|
PAPERLESS_URL = "https://paperless.b12f.io";
|
2023-02-07 14:56:19 +00:00
|
|
|
};
|
2022-02-14 09:49:49 +00:00
|
|
|
};
|
|
|
|
|
2023-10-10 11:37:17 +00:00
|
|
|
hardware.sane = {
|
|
|
|
enable = true;
|
|
|
|
extraBackends = [pkgs.hplipWithPlugin];
|
|
|
|
};
|
|
|
|
|
2023-10-07 14:45:42 +00:00
|
|
|
users.users."${psCfg.user.name}".packages = with pkgs; [
|
|
|
|
scan2paperless
|
|
|
|
sane-backends
|
|
|
|
python310Packages.img2pdf
|
|
|
|
];
|
2023-02-07 14:56:19 +00:00
|
|
|
|
2023-10-07 14:45:42 +00:00
|
|
|
home-manager.users."${psCfg.user.name}" = {
|
|
|
|
home.sessionVariables = {
|
|
|
|
SCANNER_OUTPUT_DIR = consumptionDir;
|
2022-02-14 09:49:49 +00:00
|
|
|
};
|
2023-10-07 14:45:42 +00:00
|
|
|
systemd.user.sessionVariables = {
|
|
|
|
SCANNER_OUTPUT_DIR = consumptionDir;
|
2023-08-29 11:56:18 +00:00
|
|
|
};
|
2022-02-14 09:49:49 +00:00
|
|
|
};
|
2023-10-07 14:45:42 +00:00
|
|
|
|
2023-10-07 19:11:08 +00:00
|
|
|
services.caddy = {
|
|
|
|
enable = true;
|
|
|
|
extraConfig = ''
|
2023-11-01 15:27:29 +00:00
|
|
|
paperless.b12f.io {
|
2023-10-07 19:11:08 +00:00
|
|
|
request_header Host localhost:${builtins.toString config.services.paperless.port}
|
2023-11-01 15:27:29 +00:00
|
|
|
reverse_proxy 127.0.0.1:${builtins.toString config.services.paperless.port}
|
2023-10-07 19:11:08 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
2023-10-09 20:52:28 +00:00
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${backupDir}' 0700 ${psCfg.user.name} users - -"
|
|
|
|
];
|
|
|
|
|
|
|
|
age.secrets."rclone-pie.conf" = {
|
|
|
|
file = "${flake.self}/secrets/rclone-pie.conf";
|
|
|
|
path = "/root/.config/rclone/rclone.conf";
|
|
|
|
mode = "600";
|
|
|
|
};
|
|
|
|
|
|
|
|
age.secrets."restic-password.age" = {
|
|
|
|
file = "${flake.self}/secrets/restic-password.age";
|
|
|
|
mode = "600";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.restic.backups = {
|
|
|
|
paperless = {
|
|
|
|
paths = [ backupDir ];
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-password.age".path;
|
|
|
|
# See https://www.hosting.de/blog/verschluesselte-backups-mit-rclone-und-restic-in-nextcloud/
|
|
|
|
repository = "rclone:cloud.pub.solar:/backups/Paperless";
|
|
|
|
backupPrepareCommand = "${dataDir}/paperless-manage document_exporter ${backupDir} -c -p";
|
|
|
|
rcloneConfigFile = config.age.secrets."rclone-pie.conf".path;
|
|
|
|
};
|
|
|
|
};
|
2022-02-14 09:49:49 +00:00
|
|
|
}
|