nix/container/Paper.nix

97 lines
2.6 KiB
Nix
Raw Normal View History

2024-06-26 11:23:36 +03:00
{ container, pkgs, pkgsStable, lib, config, ... }: with lib; let
2024-06-25 04:04:39 +03:00
cfg = config.container.module.paper;
2024-06-09 23:35:53 +03:00
in {
2024-06-25 04:04:39 +03:00
options = {
container.module.paper = {
enable = mkEnableOption "Paper scans manager.";
address = mkOption {
default = "10.1.0.40";
type = types.str;
};
port = mkOption {
default = 28981;
type = types.int;
};
domain = mkOption {
default = "paper.${config.container.domain}";
type = types.str;
2024-06-09 23:35:53 +03:00
};
2024-06-25 04:04:39 +03:00
storage = mkOption {
default = "${config.container.storage}/paper";
type = types.str;
2024-06-13 17:00:05 +03:00
};
2024-06-09 23:35:53 +03:00
};
2024-06-25 04:04:39 +03:00
};
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
config = mkIf cfg.enable {
systemd.tmpfiles.rules = container.mkContainerDir cfg [
"data"
];
2024-06-13 17:00:05 +03:00
2024-06-25 04:04:39 +03:00
containers.paper = container.mkContainer cfg {
bindMounts = {
"/var/lib/paperless" = {
hostPath = "${cfg.storage}/data";
isReadOnly = false;
};
"/var/lib/paperless/media" = {
hostPath = "${elemAt config.container.media.paper 0}";
isReadOnly = false;
2024-06-09 23:35:53 +03:00
};
};
2024-06-25 04:04:39 +03:00
config = { lib, ... }: container.mkContainerConfig cfg {
services.paperless = {
enable = true;
dataDir = "/var/lib/paperless";
# address = cfg.domain;
address = "0.0.0.0";
port = cfg.port;
2024-06-26 11:27:11 +03:00
# ISSUE: https://github.com/NixOS/nixpkgs/issues/322596
2024-06-26 20:27:39 +03:00
# package = pkgsStable.paperless-ngx;
2024-06-25 04:04:39 +03:00
passwordFile = pkgs.writeText "PaperlessPassword" "root";
settings = {
PAPERLESS_URL = "https://${cfg.domain}";
PAPERLESS_ADMIN_USER = "root";
PAPERLESS_DBHOST = config.container.module.postgres.address;
PAPERLESS_DBENGINE = "postgresql";
PAPERLESS_DBNAME = "paperless";
PAPERLESS_DBPASS = "paperless";
PAPERLESS_DBPORT = config.container.module.postgres.port;
PAPERLESS_DBUSER = "paperless";
PAPERLESS_OCR_LANGUAGE = "rus";
PAPERLESS_REDIS = "redis://${config.container.module.redis.address}:${toString config.container.module.redis.port}";
};
};
# HACK: This is required for TCP postgres connection.
2024-06-26 20:27:39 +03:00
systemd = {
services = {
paperless-scheduler = {
serviceConfig.PrivateNetwork = mkForce false;
wantedBy = mkForce [];
2024-06-26 20:27:39 +03:00
};
paperless-consumer = {
serviceConfig.PrivateNetwork = mkForce false;
wantedBy = mkForce [];
2024-06-26 20:27:39 +03:00
};
paperless-web = {
wantedBy = mkForce [];
2024-06-26 20:27:39 +03:00
};
paperless-task-queue = {
wantedBy = mkForce [];
2024-06-26 20:27:39 +03:00
};
};
timers.fixsystemd = {
timerConfig = {
OnBootSec = 5;
Unit = "paperless-web.service";
};
wantedBy = [ "timers.target" ];
};
2024-06-25 04:04:39 +03:00
};
2024-06-09 23:35:53 +03:00
};
};
};
}