2023-10-06 18:05:38 +02:00
|
|
|
{ config, pkgs, lib, ... }: let
|
2023-07-12 01:58:28 +02:00
|
|
|
cfg = config.services.postgresql;
|
|
|
|
in {
|
2022-06-21 01:47:36 +02:00
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
2022-06-22 20:16:57 +02:00
|
|
|
enableTCPIP = true;
|
|
|
|
authentication = pkgs.lib.mkOverride 10 ''
|
|
|
|
local all all trust
|
|
|
|
local hydra all ident map=hydra-users
|
|
|
|
host all all 127.0.0.1/32 trust
|
|
|
|
host all all ::1/128 trust
|
|
|
|
'';
|
2023-01-03 22:59:30 +01:00
|
|
|
dataDir = "${config.machineVars.dataDrives.drives.postgres}/${config.services.postgresql.package.psqlSchema}";
|
2023-07-12 01:58:28 +02:00
|
|
|
settings = {
|
|
|
|
max_connections = 150;
|
|
|
|
};
|
2022-06-21 01:47:36 +02:00
|
|
|
};
|
|
|
|
|
2022-11-08 14:20:33 +01:00
|
|
|
services.postgresqlBackup = {
|
|
|
|
enable = true;
|
2023-01-03 22:59:30 +01:00
|
|
|
location = "${config.machineVars.dataDrives.drives.backup}/postgres";
|
2022-11-08 14:20:33 +01:00
|
|
|
backupAll = true;
|
|
|
|
};
|
2023-02-25 19:06:06 +01:00
|
|
|
|
2023-07-12 01:58:28 +02:00
|
|
|
systemd.services.postgresqlBackup = {
|
|
|
|
requires = [ "postgresql.service" "data2-backup.mount" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.postgresql = {
|
|
|
|
requires = [ "data2-postgres.mount" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 3;
|
|
|
|
ReadWritePaths = [ cfg.dataDir ];
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
# PrivateMounts = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
LockPersonality = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectSystem = "strict";
|
|
|
|
ProtectProc = "invisible";
|
|
|
|
ProtectHome = true;
|
|
|
|
# PrivateNetwork = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
UMask = "0077";
|
|
|
|
# RestrictAddressFamilies = [ "AF_UNIX AF_INET AF_INET6" ];
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-02-25 19:06:06 +01:00
|
|
|
environment.systemPackages = [ config.services.postgresql.package ];
|
2022-06-21 01:47:36 +02:00
|
|
|
}
|