feat(common): setup postgresql for shared database instance

This commit is contained in:
Guz
2025-09-16 16:17:17 -03:00
parent 34326a21e1
commit 8c8170058e
2 changed files with 42 additions and 0 deletions

View File

@@ -3,5 +3,6 @@
./caddy.nix
./cloudflare.nix
./garage.nix
./postgresql.nix
];
}

41
common/postgresql.nix Normal file
View File

@@ -0,0 +1,41 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.services.postgresql;
cfgadm = config.services.pgadmin;
in {
services.postgresql = {
authentication = lib.mkForce ''
#type database DBuser origin-address auth-method
local all all trust
# ipv4
host all all 172.0.0.1/32 trust
# ipv6
host all all ::1/128 trust
'';
enable = true;
ensureDatabases = [
"nextcloud"
];
ensureUsers = [
{
name = "nextcloud";
ensureDBOwnership = true;
}
];
enableTCPIP = true;
settings = {
port = 3245;
};
};
services.caddy.virtualHosts = {
"db.local".extraConfig = ''
reverse_proxy http://localhost:${toString cfg.settings.port}
tls internal
'';
};
}