@cryptotaxi247 / infra-1 / commits / 24e6324c

non-critical-infra/postgresql: init

Martin Weinelt committed Jan 26, 2024 at 00:04 UTC 24e6324c9ba271ead517a156cc79d3c44b31be2e
1 file changed +39
non-critical-infra/modules/postgresql.nix new
+39
@@ -0,0 +1,39 @@
1 +{ config
2 +, pkgs
3 +, ...
4 +}:
5 +
6 +{
7 + fileSystems."/var/lib/postgresql" = {
8 + device = "zroot/root/postgresql";
9 + fsType = "zfs";
10 + options = [
11 + "zfsutil"
12 + ];
13 + };
14 +
15 + services.postgresql = {
16 + enable = true;
17 + enableJIT = true;
18 + package = pkgs.postgresql_16_jit;
19 + };
20 +
21 + # create database dumps
22 + services.postgresqlBackup = {
23 + enable = true;
24 + compression = "zstd";
25 + # pulled in through the backup job
26 + startAt = [];
27 + };
28 +
29 + # include postgres dumps in the backup
30 + services.backup = {
31 + includes = [
32 + "/var/backup/postgresql"
33 + ];
34 + wantedUnits = if config.services.postgresqlBackup.databases == [] then
35 + [ "postgresqlBackup.service" ]
36 + else
37 + map (db: "postgresqlBackup-${db}.service") config.services.postgresqlBackup.databases;
38 + };
39 +}