diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2025-03-14 00:28:35 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2025-03-14 01:03:28 +0100 |
commit | 8b1cbf7db2e272f74712ca3c8937028925843bd9 (patch) | |
tree | fa9766539b68b669b60409168a1b4361556c37a9 | |
parent | 9a2bbc9550bbf6c6cf7f6184159818acf9e0c63c (diff) | |
download | Nix-8b1cbf7db2e272f74712ca3c8937028925843bd9.tar.gz Nix-8b1cbf7db2e272f74712ca3c8937028925843bd9.tar.zst Nix-8b1cbf7db2e272f74712ca3c8937028925843bd9.zip |
Zoldene database config
-rw-r--r-- | deploy/flake.lock | 4 | ||||
-rw-r--r-- | flake.lock | 4 | ||||
-rw-r--r-- | flakes/flake.lock | 2 | ||||
-rw-r--r-- | systems/zoldene/base.nix | 1 | ||||
-rw-r--r-- | systems/zoldene/database.nix | 50 | ||||
-rw-r--r-- | systems/zoldene/logging.nix | 34 |
6 files changed, 56 insertions, 39 deletions
diff --git a/deploy/flake.lock b/deploy/flake.lock index 610fcbc..6c3e517 100644 --- a/deploy/flake.lock +++ b/deploy/flake.lock | |||
@@ -2848,7 +2848,7 @@ | |||
2848 | }, | 2848 | }, |
2849 | "locked": { | 2849 | "locked": { |
2850 | "lastModified": 1, | 2850 | "lastModified": 1, |
2851 | "narHash": "sha256-HXTL7vVayoRljwcYIroiMTrZAKlmhJwTXjCc15CO8iI=", | 2851 | "narHash": "sha256-sLwKmVmedkPJkkDRn3bWtQqsGAM6UdqVpHtfB5oQJ84=", |
2852 | "path": "../flakes", | 2852 | "path": "../flakes", |
2853 | "type": "path" | 2853 | "type": "path" |
2854 | }, | 2854 | }, |
@@ -4042,7 +4042,7 @@ | |||
4042 | }, | 4042 | }, |
4043 | "locked": { | 4043 | "locked": { |
4044 | "lastModified": 1, | 4044 | "lastModified": 1, |
4045 | "narHash": "sha256-T3G0k/1kcFs28OETmnqzOVm5YlKFilOc6jpHE6ZXS/s=", | 4045 | "narHash": "sha256-OHoDl3aFFCQ6NOfRGefPo5xJazDKqnAo+a6GJw6VhNc=", |
4046 | "path": "../systems/zoldene", | 4046 | "path": "../systems/zoldene", |
4047 | "type": "path" | 4047 | "type": "path" |
4048 | }, | 4048 | }, |
@@ -2729,7 +2729,7 @@ | |||
2729 | }, | 2729 | }, |
2730 | "locked": { | 2730 | "locked": { |
2731 | "lastModified": 1, | 2731 | "lastModified": 1, |
2732 | "narHash": "sha256-HXTL7vVayoRljwcYIroiMTrZAKlmhJwTXjCc15CO8iI=", | 2732 | "narHash": "sha256-sLwKmVmedkPJkkDRn3bWtQqsGAM6UdqVpHtfB5oQJ84=", |
2733 | "path": "./flakes", | 2733 | "path": "./flakes", |
2734 | "type": "path" | 2734 | "type": "path" |
2735 | }, | 2735 | }, |
@@ -4058,7 +4058,7 @@ | |||
4058 | }, | 4058 | }, |
4059 | "locked": { | 4059 | "locked": { |
4060 | "lastModified": 1, | 4060 | "lastModified": 1, |
4061 | "narHash": "sha256-T3G0k/1kcFs28OETmnqzOVm5YlKFilOc6jpHE6ZXS/s=", | 4061 | "narHash": "sha256-OHoDl3aFFCQ6NOfRGefPo5xJazDKqnAo+a6GJw6VhNc=", |
4062 | "path": "../systems/zoldene", | 4062 | "path": "../systems/zoldene", |
4063 | "type": "path" | 4063 | "type": "path" |
4064 | }, | 4064 | }, |
diff --git a/flakes/flake.lock b/flakes/flake.lock index 2765727..c06e084 100644 --- a/flakes/flake.lock +++ b/flakes/flake.lock | |||
@@ -3962,7 +3962,7 @@ | |||
3962 | }, | 3962 | }, |
3963 | "locked": { | 3963 | "locked": { |
3964 | "lastModified": 1, | 3964 | "lastModified": 1, |
3965 | "narHash": "sha256-T3G0k/1kcFs28OETmnqzOVm5YlKFilOc6jpHE6ZXS/s=", | 3965 | "narHash": "sha256-OHoDl3aFFCQ6NOfRGefPo5xJazDKqnAo+a6GJw6VhNc=", |
3966 | "path": "../systems/zoldene", | 3966 | "path": "../systems/zoldene", |
3967 | "type": "path" | 3967 | "type": "path" |
3968 | }, | 3968 | }, |
diff --git a/systems/zoldene/base.nix b/systems/zoldene/base.nix index 71b8209..d580f99 100644 --- a/systems/zoldene/base.nix +++ b/systems/zoldene/base.nix | |||
@@ -14,6 +14,7 @@ in | |||
14 | ./virtualisation.nix | 14 | ./virtualisation.nix |
15 | ./certificates.nix | 15 | ./certificates.nix |
16 | ./synapse.nix | 16 | ./synapse.nix |
17 | ./database.nix | ||
17 | ]; | 18 | ]; |
18 | 19 | ||
19 | services.borgBackup.enable = true; | 20 | services.borgBackup.enable = true; |
diff --git a/systems/zoldene/database.nix b/systems/zoldene/database.nix new file mode 100644 index 0000000..2eb6cd9 --- /dev/null +++ b/systems/zoldene/database.nix | |||
@@ -0,0 +1,50 @@ | |||
1 | { pkgs, config, lib, nodes, ... }: | ||
2 | let | ||
3 | psqlVersion = pkgs.postgresql_16.psqlSchema; | ||
4 | in | ||
5 | { | ||
6 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/postgresql" = | ||
7 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/postgresql"; options.mountpoint = "legacy"; }; | ||
8 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/postgresql/${psqlVersion}" = | ||
9 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/postgresql/${psqlVersion}"; options.mountpoint = "legacy"; }; | ||
10 | environment.persistence."/persist/zfast".directories = [ | ||
11 | { | ||
12 | directory = "/var/lib/postgresql"; | ||
13 | user = config.users.users.postgres.name; | ||
14 | group = config.users.users.postgres.group; | ||
15 | mode = "0755"; | ||
16 | } | ||
17 | { | ||
18 | directory = "/var/lib/postgresql/${psqlVersion}"; | ||
19 | user = config.users.users.postgres.name; | ||
20 | group = config.users.users.postgres.group; | ||
21 | mode = "0755"; | ||
22 | } | ||
23 | ]; | ||
24 | systemd.services.postgresql.after = [ | ||
25 | "var-lib-postgresql.mount" | ||
26 | "var-lib-postgresql-16.mount" | ||
27 | "persist-zfast-var-lib-postgresql.mount" | ||
28 | "persist-zfast-var-lib-postgresql-16.mount" | ||
29 | ]; | ||
30 | systemd.services.postgresql.unitConfig = { | ||
31 | BindsTo = [ | ||
32 | "var-lib-postgresql.mount" | ||
33 | "var-lib-postgresql-16.mount" | ||
34 | "persist-zfast-var-lib-postgresql.mount" | ||
35 | "persist-zfast-var-lib-postgresql-16.mount" | ||
36 | ]; | ||
37 | }; | ||
38 | |||
39 | services.postgresql = { | ||
40 | enable = true; | ||
41 | package = pkgs.postgresql_16; | ||
42 | settings.listen_addresses = lib.mkForce (builtins.concatStringsSep "," [ | ||
43 | "localhost" | ||
44 | config.hostEnv.wireguard.ip | ||
45 | ]); | ||
46 | authentication = '' | ||
47 | host replication postgres ${nodes.backup-2.config.hostEnv.wireguard.ip}/32 ident | ||
48 | ''; | ||
49 | }; | ||
50 | } | ||
diff --git a/systems/zoldene/logging.nix b/systems/zoldene/logging.nix index 943d5f1..8187d50 100644 --- a/systems/zoldene/logging.nix +++ b/systems/zoldene/logging.nix | |||
@@ -35,31 +35,14 @@ let | |||
35 | }; | 35 | }; |
36 | }; | 36 | }; |
37 | yamlFormat = pkgs.formats.yaml {}; | 37 | yamlFormat = pkgs.formats.yaml {}; |
38 | psqlVersion = pkgs.postgresql_16.psqlSchema; | ||
39 | in | 38 | in |
40 | { | 39 | { |
41 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/loki" = | 40 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/loki" = |
42 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/loki"; options.mountpoint = "legacy"; }; | 41 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/loki"; options.mountpoint = "legacy"; }; |
43 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/fluentbit" = | 42 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/fluentbit" = |
44 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/fluentbit"; options.mountpoint = "legacy"; }; | 43 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/fluentbit"; options.mountpoint = "legacy"; }; |
45 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/postgresql" = | ||
46 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/postgresql"; options.mountpoint = "legacy"; }; | ||
47 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/postgresql/${psqlVersion}" = | ||
48 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/postgresql/${psqlVersion}"; options.mountpoint = "legacy"; }; | ||
49 | environment.persistence."/persist/zfast".directories = [ | 44 | environment.persistence."/persist/zfast".directories = [ |
50 | { | 45 | { |
51 | directory = "/var/lib/postgresql"; | ||
52 | user = config.users.users.postgres.name; | ||
53 | group = config.users.users.postgres.group; | ||
54 | mode = "0755"; | ||
55 | } | ||
56 | { | ||
57 | directory = "/var/lib/postgresql/${psqlVersion}"; | ||
58 | user = config.users.users.postgres.name; | ||
59 | group = config.users.users.postgres.group; | ||
60 | mode = "0755"; | ||
61 | } | ||
62 | { | ||
63 | directory = "/var/lib/fluentbit"; | 46 | directory = "/var/lib/fluentbit"; |
64 | user = config.users.users.fluentbit.name; | 47 | user = config.users.users.fluentbit.name; |
65 | group = config.users.users.fluentbit.group; | 48 | group = config.users.users.fluentbit.group; |
@@ -126,24 +109,8 @@ in | |||
126 | ]; | 109 | ]; |
127 | }; | 110 | }; |
128 | }; | 111 | }; |
129 | systemd.services.postgresql.after = [ | ||
130 | "var-lib-postgresql.mount" | ||
131 | "var-lib-postgresql-16.mount" | ||
132 | "persist-zfast-var-lib-postgresql.mount" | ||
133 | "persist-zfast-var-lib-postgresql-16.mount" | ||
134 | ]; | ||
135 | systemd.services.postgresql.unitConfig = { | ||
136 | BindsTo = [ | ||
137 | "var-lib-postgresql.mount" | ||
138 | "var-lib-postgresql-16.mount" | ||
139 | "persist-zfast-var-lib-postgresql.mount" | ||
140 | "persist-zfast-var-lib-postgresql-16.mount" | ||
141 | ]; | ||
142 | }; | ||
143 | 112 | ||
144 | services.postgresql = { | 113 | services.postgresql = { |
145 | enable = true; | ||
146 | package = pkgs.postgresql_16; | ||
147 | ensureDatabases = [ "fluentbit" ]; | 114 | ensureDatabases = [ "fluentbit" ]; |
148 | ensureUsers = [ | 115 | ensureUsers = [ |
149 | { | 116 | { |
@@ -152,7 +119,6 @@ in | |||
152 | } | 119 | } |
153 | ]; | 120 | ]; |
154 | }; | 121 | }; |
155 | |||
156 | environment.systemPackages = [ | 122 | environment.systemPackages = [ |
157 | pkgs.fluent-bit | 123 | pkgs.fluent-bit |
158 | ]; | 124 | ]; |