From 813e73365785f6fa47c6857d744fcce89883360f Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 17 Sep 2025 18:59:40 +0200 Subject: [PATCH 1/2] nixos/pgbackrest: add commands option for specific settings These settings are documented here: https://pgbackrest.org/configuration.html It's useful to be able to define specific configuration for separate commands, for example for fixing a failing test in the next update. --- nixos/modules/services/backup/pgbackrest.nix | 53 +++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/backup/pgbackrest.nix b/nixos/modules/services/backup/pgbackrest.nix index 381589bc742d..d6dd7b1f04c8 100644 --- a/nixos/modules/services/backup/pgbackrest.nix +++ b/nixos/modules/services/backup/pgbackrest.nix @@ -55,6 +55,9 @@ let fullConfig = { global = normalize (cfg.settings // flattenWithIndex cfg.repos "repo"); } + // lib.mapAttrs' ( + cmd: settings: lib.nameValuePair "global:${cmd}" (normalize settings) + ) cfg.commands // lib.mapAttrs ( _: cfg': normalize (cfg'.settings // flattenWithIndex cfg'.instances "pg") ) cfg.stanzas; @@ -95,7 +98,6 @@ in }; # TODO: Add enableServer option and corresponding pgBackRest TLS server service. - # TODO: Allow command-specific options # TODO: Write wrapper around pgbackrest to turn --repo= into --repo= # The following two are dependent on improvements upstream: # https://github.com/pgbackrest/pgbackrest/issues/2621 @@ -328,6 +330,55 @@ in } ''; }; + + commands = + lib.genAttrs + [ + # List of commands from https://pgbackrest.org/command.html: + "annotate" + "archive-get" + "archive-push" + "backup" + "check" + "expire" + "help" + "info" + "repo-get" + "repo-ls" + "restore" + "server" + "server-ping" + "stanza-create" + "stanza-delete" + "stanza-upgrade" + "start" + "stop" + "verify" + "version" + ] + ( + command: + lib.mkOption { + type = lib.types.submodule { + freeformType = settingsType; + + # The following options are not fully supported / tested, yet, but point to files with secrets. + # Users can already set those options, but we'll force non-store paths. + options.tls-server-cert-file = secretPathOption; + options.tls-server-key-file = secretPathOption; + }; + default = { }; + description = '' + Options for the '${command}' command. + + An attribute set of options as described in: + + + All globally available options, i.e. all except stanza options, can be used. + Repository options should be set via [`repos`](#opt-services.pgbackrest.repos) instead. + ''; + } + ); }; config = lib.mkIf cfg.enable ( From 49f3a9f7cbb34c23f3d2661d98e6b6bcdc915741 Mon Sep 17 00:00:00 2001 From: Rafael Ieda Date: Wed, 17 Sep 2025 09:01:52 -0300 Subject: [PATCH 2/2] pgbackrest: 2.55.1 -> 2.56.0 --- nixos/modules/services/backup/pgbackrest.nix | 3 +++ pkgs/by-name/pg/pgbackrest/package.nix | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/backup/pgbackrest.nix b/nixos/modules/services/backup/pgbackrest.nix index d6dd7b1f04c8..6e5880ba1f90 100644 --- a/nixos/modules/services/backup/pgbackrest.nix +++ b/nixos/modules/services/backup/pgbackrest.nix @@ -459,6 +459,9 @@ in user = "postgres"; }; }; + # If PostgreSQL runs on the same machine, any restore will have to be done with that user. + # Keeping the lock file in a directory writeable by the postgres user prevents errors. + services.pgbackrest.commands.restore.lock-path = "/tmp/postgresql"; services.postgresql.identMap = '' postgres pgbackrest postgres ''; diff --git a/pkgs/by-name/pg/pgbackrest/package.nix b/pkgs/by-name/pg/pgbackrest/package.nix index 9128586315b5..122516cbefbd 100644 --- a/pkgs/by-name/pg/pgbackrest/package.nix +++ b/pkgs/by-name/pg/pgbackrest/package.nix @@ -20,13 +20,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "pgbackrest"; - version = "2.55.1"; + version = "2.56.0"; src = fetchFromGitHub { owner = "pgbackrest"; repo = "pgbackrest"; tag = "release/${finalAttrs.version}"; - hash = "sha256-A1dTywcCHBu7Ml0Q9k//VVPFN1C3kmmMkq4ok9T4g94="; + hash = "sha256-GDHpeTz85cgKTbcuaTlwJ1SUNMedSylqKWdrgH8Zp8Q="; }; strictDeps = true;