dotfiles/modules/nixos/services/postgresql/default.nix

69 lines
1.2 KiB
Nix
Raw Normal View History

2025-10-01 19:51:55 -05:00
{ flake, ... }:
let
inherit (flake.config.machines.devices)
ceres
;
inherit (flake.config.services.instances)
postgresql
2025-10-09 04:58:35 -05:00
firefly-iii
2025-10-01 19:51:55 -05:00
;
service = postgresql;
in
{
services = {
postgresqlBackup = {
enable = true;
location = service.paths.path0;
databases = [
"mastodon"
"nextcloud"
"peertube"
"forgejo"
];
};
postgresql = {
enable = true;
2025-10-09 05:30:23 -05:00
# ensureDatabases = [ firefly-iii.name ];
# ensureUsers = [
# {
# name = firefly-iii.name;
# ensureDBOwnership = true;
# }
# ];
2025-10-01 19:51:55 -05:00
};
};
networking = {
firewall = {
allowedTCPPorts = [
service.ports.port0
];
};
};
fileSystems."/var/lib/postgresql" = {
device = service.paths.path0;
fsType = "none";
options = [
"bind"
];
depends = [
ceres.storage0.mount
];
};
systemd.tmpfiles.rules = [
"Z ${service.paths.path0} 700 ${service.name} ${service.name} -"
];
users.users.${service.name}.extraGroups = [
"nextcloud"
"mastodon"
"forgejo"
];
system.activationScripts.postgresCommands = ''
chown -R ${service.name}:${service.name} ${service.paths.path0}
'';
}