lib > builtins

This commit is contained in:
asyncnomi 2025-08-03 01:05:02 +02:00
parent 47ccd698a9
commit 22f93f23ed
6 changed files with 39 additions and 38 deletions

View file

@ -28,7 +28,7 @@ in
# Replication tasks are not authenticated
# The wireguard mesh cryptographically
# ensures the sender is who we expect.
authentication = lib.mkForce (builtins.concatStringsSep "\n" ([''
authentication = lib.mkForce (lib.strings.concatStringsSep "\n" ([''
#type database DBuser auth-method optional_ident_map
local all all peer map=superuser_map
'']
@ -36,7 +36,7 @@ in
(map (slaveName: let slaveNode = nodes.${slaveName}; in
"host replication replication 172.19.${toString slaveNode.zone}.${toString slaveNode.id}/32 trust"
) mapping.db.slaves)
++ lib.optionals (builtins.elem myName mapping.db.slaves) [
++ lib.optionals (lib.elem myName mapping.db.slaves) [
"host replication replication ${masterIP}/32 trust"
]));
ensureUsers = lib.mkIf (myName == mapping.db.master) [{
@ -55,7 +55,7 @@ in
} // lib.optionalAttrs (myName == mapping.db.master) {
wal_sender_timeout = "60s";
wal_keep_size = 1000; # In MB
} // lib.optionalAttrs (builtins.elem myName mapping.db.slaves) {
} // lib.optionalAttrs (lib.elem myName mapping.db.slaves) {
wal_receiver_timeout = "60s";
hot_standby = "on";
primary_conninfo = "host=${masterIP} port=5432 user=replication";
@ -64,7 +64,7 @@ in
# This preStart script sync the slaves to the master
# systemd.services.<name>.preStart has a mergeable type,
# this code will be prepend to the default one
systemd.services.postgresql.preStart = lib.mkIf (builtins.elem myName mapping.db.slaves) (lib.mkBefore ''
systemd.services.postgresql.preStart = lib.mkIf (lib.elem myName mapping.db.slaves) (lib.mkBefore ''
if ! test -e ${cfg.dataDir}/PG_VERSION; then
echo "Setting up PostgreSQL slave replication..."