Merge pull request #249792 from teto/postgresql-quality-of-life-changes

services.postgres: move the generated statement at the top of the file
This commit is contained in:
Maximilian Bosch 2023-09-27 16:22:58 +02:00 committed by GitHub
commit b9bff72147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,12 +106,14 @@ in
identMap = mkOption { identMap = mkOption {
type = types.lines; type = types.lines;
default = ""; default = "";
example = literalExample ''
map-name-0 system-username-0 database-username-0
map-name-1 system-username-1 database-username-1
'';
description = lib.mdDoc '' description = lib.mdDoc ''
Defines the mapping from system users to database users. Defines the mapping from system users to database users.
The general form is: See the [auth doc](https://postgresql.org/docs/current/auth-username-maps.html).
map-name system-username database-username
''; '';
}; };
@ -128,6 +130,11 @@ in
initialScript = mkOption { initialScript = mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = null; default = null;
example = literalExpression ''
pkgs.writeText "init-sql-script" '''
alter user postgres with password 'myPassword';
''';'';
description = lib.mdDoc '' description = lib.mdDoc ''
A file containing SQL statements to execute on first startup. A file containing SQL statements to execute on first startup.
''; '';
@ -464,13 +471,16 @@ in
services.postgresql.dataDir = mkDefault "/var/lib/postgresql/${cfg.package.psqlSchema}"; services.postgresql.dataDir = mkDefault "/var/lib/postgresql/${cfg.package.psqlSchema}";
services.postgresql.authentication = mkAfter services.postgresql.authentication = mkMerge [
(mkBefore "# Generated file; do not edit!")
(mkAfter
'' ''
# Generated file; do not edit! # default value of services.postgresql.authentication
local all all peer local all all peer
host all all 127.0.0.1/32 md5 host all all 127.0.0.1/32 md5
host all all ::1/128 md5 host all all ::1/128 md5
''; '')
];
users.users.postgres = users.users.postgres =
{ name = "postgres"; { name = "postgres";