2024-10-06 15:25:05 -05:00
|
|
|
{flake, ...}: let
|
2025-01-08 19:06:14 -06:00
|
|
|
inherit
|
|
|
|
(flake.config.machines.devices)
|
|
|
|
server
|
|
|
|
;
|
|
|
|
inherit
|
|
|
|
(flake.config.services.instances)
|
|
|
|
postgresql
|
|
|
|
;
|
2024-10-19 18:22:29 -05:00
|
|
|
|
|
|
|
service = postgresql;
|
2024-10-06 15:25:05 -05:00
|
|
|
in {
|
|
|
|
services = {
|
|
|
|
postgresqlBackup = {
|
|
|
|
enable = true;
|
2024-10-19 18:22:29 -05:00
|
|
|
location = service.paths.path0;
|
2025-01-08 19:06:14 -06:00
|
|
|
databases = [
|
|
|
|
"mastodon"
|
|
|
|
"nextcloud"
|
|
|
|
"peertube"
|
|
|
|
"forgejo"
|
|
|
|
"wiki"
|
|
|
|
];
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
postgresql = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
2024-10-19 18:22:29 -05:00
|
|
|
service.ports.port0
|
2024-10-06 15:25:05 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fileSystems."/var/lib/postgresql" = {
|
2024-10-19 18:22:29 -05:00
|
|
|
device = service.paths.path0;
|
2024-10-06 15:25:05 -05:00
|
|
|
fsType = "none";
|
2025-01-08 19:06:14 -06:00
|
|
|
options = [
|
|
|
|
"bind"
|
|
|
|
];
|
|
|
|
depends = [
|
|
|
|
server.storage0.mount
|
|
|
|
];
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
|
2025-01-08 19:06:14 -06:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"Z ${service.paths.path0} 700 ${service.name} ${service.name} -"
|
|
|
|
];
|
2024-10-06 15:25:05 -05:00
|
|
|
|
2025-01-08 19:06:14 -06:00
|
|
|
users.users.${service.name}.extraGroups = [
|
|
|
|
"nextcloud"
|
|
|
|
"mastodon"
|
|
|
|
"forgejo"
|
|
|
|
];
|
2024-10-06 15:25:05 -05:00
|
|
|
|
|
|
|
system.activationScripts.postgresCommands = ''
|
2024-10-19 18:22:29 -05:00
|
|
|
chown -R ${service.name}:${service.name} ${service.paths.path0}
|
2024-10-06 15:25:05 -05:00
|
|
|
'';
|
|
|
|
}
|