nixos-infra/services/nextcloud/database.nix
2026-04-01 09:54:15 +03:00

35 lines
628 B
Nix

{
config,
lib,
...
}:
let
pgsqlEnable = config.machine.postgresql.enable;
cfg = config.machine.nextcloud;
in
with lib;
mkIf cfg.enable {
services.nextcloud.config =
if pgsqlEnable then
{
dbtype = "pgsql";
dbhost = "localhost:${toString config.machine.postgresql.port}";
}
else
{
dbtype = "sqlite";
dbhost = "localhost";
};
services.postgresql =
with lib;
mkIf pgsqlEnable {
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{
name = "nextcloud";
ensureDBOwnership = true;
}
];
};
}