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

48 lines
1.3 KiB
Nix

{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.docs-manager;
cfg = moduleCfg.postgres;
hostDataPath = "${common.dataDir}/${moduleCfg.paperless-ngx.name}";
in
{
imports = [ ./config.nix ];
options.selfhosted.docs-manager.postgres = {
name = mkOption {
type = types.str;
};
};
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers."${cfg.name}" = {
image = "docker.io/library/postgres:17.7";
environmentFiles = [ config.sops.templates."paperless-ngx-db.env".path ];
volumes = [
"${hostDataPath}/db:/var/lib/postgresql/data"
];
log-driver = "journald";
extraOptions = [
"--network=${common.network.name}"
"--health-cmd=pg_isready -U paperless"
"--health-interval=30s"
"--health-timeout=10s"
"--health-retries=3"
];
};
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
preStart = ''
mkdir -p ${hostDataPath}/db
'';
};
};
}