Files
aloslider c92b90e406 Small modules config restructure
Changed variables names in every module
2026-10-31 19:48:50 +03:00

71 lines
2.3 KiB
Nix

{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.docs-manager;
cfg = moduleCfg.paperless-ngx;
hostDataPath = "${common.dataDir}/${cfg.name}";
in
{
imports = [ ./config.nix ];
options.selfhosted.docs-manager.paperless-ngx = {
name = mkOption {
type = types.str;
};
subdomain = mkOption {
type = types.str;
};
hostHttpPort = mkOption {
type = types.port;
};
};
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers."${cfg.name}" = {
image = "ghcr.io/paperless-ngx/paperless-ngx:2.15.3";
ports = [
"0.0.0.0:${toString cfg.hostHttpPort}:8000"
];
environmentFiles = [
config.sops.templates."paperless-ngx.env".path
];
volumes = [
"${hostDataPath}/data:/usr/src/paperless/data"
"${hostDataPath}/media:/usr/src/paperless/media"
"${hostDataPath}/export:/usr/src/paperless/export"
"${hostDataPath}/consume:/usr/src/paperless/consume"
];
log-driver = "journald";
extraOptions = [
"--network=${common.network.name}"
"--health-cmd=curl -fsS http://127.0.0.1:8000/"
"--health-interval=30s"
"--health-timeout=10s"
"--health-retries=5"
"--health-start-period=90s"
];
};
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
after = [
"${common.backend}-${moduleCfg.redis.name}.service"
"${common.backend}-${moduleCfg.postgres.name}.service"
"${common.backend}-${moduleCfg.tika.gotenbergName}.service"
"${common.backend}-${moduleCfg.tika.name}.service"
];
preStart = ''
mkdir -p ${hostDataPath}/data ${hostDataPath}/media ${hostDataPath}/export ${hostDataPath}/consume
chown -R ${common.user.uid}:${common.group.gid} ${hostDataPath}/data ${hostDataPath}/media ${hostDataPath}/export ${hostDataPath}/consume
chmod -R 0775 ${hostDataPath}/data ${hostDataPath}/media ${hostDataPath}/export ${hostDataPath}/consume
'';
};
};
}