From 4d0f802848240a4985af10072912356cd0394d3f Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 8 Jan 2025 16:05:38 +0100 Subject: [PATCH] nixos/postgresql: fix condition for readwritepaths In the case that the user wants to provide a custom data directory, we need to grant `ReadWritePaths` for that directory. Previously this would not happen when `/var/lib/postgresql` was used, because the condition was not in fact checking for the default data directory, creating a gap in then if-else scenario. Fixes: #371680 --- nixos/modules/services/databases/postgresql.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 59fef3824d85..51d707c6594b 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -733,10 +733,12 @@ in ] ++ lib.optionals (any extensionInstalled [ "plv8" ]) [ "@pkey" ]; UMask = if groupAccessAvailable then "0027" else "0077"; } - (mkIf (cfg.dataDir != "/var/lib/postgresql") { + (mkIf (cfg.dataDir != "/var/lib/postgresql/${cfg.package.psqlSchema}") { + # The user provides their own data directory ReadWritePaths = [ cfg.dataDir ]; }) (mkIf (cfg.dataDir == "/var/lib/postgresql/${cfg.package.psqlSchema}") { + # Provision the default data directory StateDirectory = "postgresql postgresql/${cfg.package.psqlSchema}"; StateDirectoryMode = if groupAccessAvailable then "0750" else "0700"; })