nixos/postgresql: improve local peer authentication with default map

This allows to easily map allowed database roles to system users.
This commit is contained in:
Wolfgang Walther 2025-05-05 10:31:21 +02:00
parent f934044282
commit 3d29b7d3a2
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1
4 changed files with 58 additions and 1 deletions

View file

@ -54,6 +54,9 @@ let
services.postgresql = {
inherit package;
enable = true;
identMap = ''
postgres root postgres
'';
# TODO(@Ma27) split this off into its own VM test and move a few other
# extension tests to use postgresqlTestExtension.
extensions = ps: with ps; [ plv8 ];
@ -73,7 +76,7 @@ let
in
''
def check_count(statement, lines):
return 'test $(sudo -u postgres psql postgres -tAc "{}"|wc -l) -eq {}'.format(
return 'test $(psql -U postgres postgres -tAc "{}"|wc -l) -eq {}'.format(
statement, lines
)