X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fdatabases%2Fpostgresql_replication.nix;h=135bbed0d90bfbc9cd239727ab3ddbfc5a88e649;hb=4c4652aabf2cb3ac8b40f2856eca07a1df9c27e0;hp=6ac2455a9eea3632c783de3a8fc937aedbe57087;hpb=9f16e659f129dd8acab7d086ef9822673a01ba06;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/databases/postgresql_replication.nix b/modules/private/databases/postgresql_replication.nix index 6ac2455..135bbed 100644 --- a/modules/private/databases/postgresql_replication.nix +++ b/modules/private/databases/postgresql_replication.nix @@ -62,9 +62,8 @@ in users.groups.postgres.gid = config.ids.gids.postgres; environment.systemPackages = [ cfg.mainPackage ]; - secrets.keys = lib.flatten (lib.mapAttrsToList (name: hcfg: [ - { - dest = "postgresql_replication/${name}/recovery.conf"; + secrets.keys = lib.listToAttrs (lib.flatten (lib.mapAttrsToList (name: hcfg: [ + (lib.nameValuePair "postgresql_replication/${name}/recovery.conf" { user = "postgres"; group = "postgres"; permissions = "0400"; @@ -73,16 +72,14 @@ in primary_conninfo = '${hcfg.connection}?sslmode=require' primary_slot_name = '${hcfg.slot}' ''; - } - { - dest = "postgresql_replication/${name}/connection_string"; + }) + (lib.nameValuePair "postgresql_replication/${name}/connection_string" { user = "postgres"; group = "postgres"; permissions = "0400"; text = hcfg.connection; - } - { - dest = "postgresql_replication/${name}/postgresql.conf"; + }) + (lib.nameValuePair "postgresql_replication/${name}/postgresql.conf" { user = "postgres"; group = "postgres"; permissions = "0400"; @@ -94,8 +91,8 @@ in data_directory = '${dataDir}' wal_level = logical ''; - } - ]) cfg.hosts); + }) + ]) cfg.hosts)); services.cron = { enable = true; @@ -119,7 +116,7 @@ in ${hcfg.package}/bin/pg_dumpall -h ${dataDir} -f ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql ''; u = pkgs.callPackage ./utils.nix {}; - cleanup_script = pkgs.writeScript "cleanup_postgresql_${name}" (u.keepLastNDumps "sql" backupDir 12); + cleanup_script = pkgs.writeScript "cleanup_postgresql_${name}" (u.keepLastNDumps "sql" backupDir 6); in [ "0 22,4,10,16 * * * postgres ${backup_script}" "0 3 * * * postgres ${cleanup_script}"