2024-06-13 17:00:05 +03:00
|
|
|
{ container, pkgs, util, lib, ... } @args: let
|
2024-06-09 23:35:53 +03:00
|
|
|
cfg = container.config.paper;
|
|
|
|
in {
|
|
|
|
systemd.tmpfiles.rules = container.mkContainerDir cfg [
|
|
|
|
"data"
|
|
|
|
];
|
|
|
|
|
|
|
|
containers.paper = container.mkContainer cfg {
|
|
|
|
bindMounts = {
|
|
|
|
"/var/lib/paperless" = {
|
|
|
|
hostPath = "${cfg.storage}/data";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
2024-06-13 17:00:05 +03:00
|
|
|
"/var/lib/paperless/media" = {
|
|
|
|
hostPath = "${lib.elemAt cfg.paper 0}";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
2024-06-09 23:35:53 +03:00
|
|
|
};
|
|
|
|
|
2024-06-14 02:58:39 +03:00
|
|
|
config = { lib, ... }: container.mkContainerConfig cfg {
|
2024-06-13 17:00:05 +03:00
|
|
|
environment.systemPackages = with pkgs; [ postgresql inetutils ];
|
|
|
|
|
2024-06-09 23:35:53 +03:00
|
|
|
services.paperless = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/paperless";
|
|
|
|
# address = cfg.domain;
|
|
|
|
address = "0.0.0.0";
|
|
|
|
port = cfg.port;
|
|
|
|
passwordFile = pkgs.writeText "PaperlessPassword" "root";
|
|
|
|
settings = {
|
2024-06-13 17:00:05 +03:00
|
|
|
PAPERLESS_URL = "https://${cfg.domain}";
|
2024-06-09 23:35:53 +03:00
|
|
|
PAPERLESS_ADMIN_USER = "root";
|
|
|
|
PAPERLESS_DBHOST = container.config.postgres.address;
|
|
|
|
PAPERLESS_DBENGINE = "postgresql";
|
|
|
|
PAPERLESS_DBNAME = "paperless";
|
|
|
|
PAPERLESS_DBPASS = "paperless";
|
|
|
|
PAPERLESS_DBPORT = container.config.postgres.port;
|
|
|
|
PAPERLESS_DBUSER = "paperless";
|
|
|
|
PAPERLESS_OCR_LANGUAGE = "rus";
|
|
|
|
PAPERLESS_REDIS = "redis://${container.config.redis.address}:${toString container.config.redis.port}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# HACK: This is required for TCP postgres connection.
|
|
|
|
systemd.services.paperless-scheduler.serviceConfig = {
|
|
|
|
PrivateNetwork = lib.mkForce false;
|
|
|
|
};
|
|
|
|
systemd.services.paperless-consumer.serviceConfig = {
|
|
|
|
PrivateNetwork = lib.mkForce false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|