diff --git a/nixos/doc/manual/release-notes/rl-2009.xml b/nixos/doc/manual/release-notes/rl-2009.xml index 85679e482722..71667c854bc3 100644 --- a/nixos/doc/manual/release-notes/rl-2009.xml +++ b/nixos/doc/manual/release-notes/rl-2009.xml @@ -666,11 +666,19 @@ services.dokuwiki."mywiki" = { The option is now set to "/var/lib/postgresql/${cfg.package.psqlSchema}" regardless of your - . Users with an existing postgresql install that have a of 17.09 or below + . Users with an existing postgresql install that have a of 17.03 or below should double check what the value of their option is (/var/db/postgresql) and then explicitly set this value to maintain compatibility: services.postgresql.dataDir = "/var/db/postgresql"; + + + + The postgresql module now expects there to be a database super user account called postgres regardless of your . Users + with an existing postgresql install that have a of 17.03 or below should run the following SQL statements as a + database super admin user before upgrading: + +CREATE ROLE postgres LOGIN SUPERUSER; diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 3e16b5907dd0..2bb2ba73996c 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -225,14 +225,15 @@ in Contents of the recovery.conf file. ''; }; + superUser = mkOption { type = types.str; - default= if versionAtLeast config.system.stateVersion "17.09" then "postgres" else "root"; + default = "postgres"; internal = true; + readOnly = true; description = '' - NixOS traditionally used 'root' as superuser, most other distros use 'postgres'. - From 17.09 we also try to follow this standard. Internal since changing this value - would lead to breakage while setting up databases. + PostgreSQL superuser account to use for various operations. Internal since changing + this value would lead to breakage while setting up databases. ''; }; }; @@ -336,7 +337,7 @@ in setupScript = pkgs.writeScript "postgresql-setup" ('' #!${pkgs.runtimeShell} -e - PSQL="${pkgs.utillinux}/bin/runuser -u ${cfg.superUser} -- psql --port=${toString cfg.port}" + PSQL="psql --port=${toString cfg.port}" while ! $PSQL -d postgres -c "" 2> /dev/null; do if ! kill -0 "$MAINPID"; then exit 1; fi @@ -362,7 +363,7 @@ in '') cfg.ensureUsers} ''); in - "+${setupScript}"; + "${setupScript}"; } (mkIf (cfg.dataDir == "/var/lib/postgresql/${cfg.package.psqlSchema}") { StateDirectory = "postgresql postgresql/${cfg.package.psqlSchema}";