postgresql: Use runuser instead of sudo

Currently, sudo doesn't work in a NixOS container running inside a Nix
build, because Nix's seccomp filter doesn't allow setuid programs. In
any case, runuser is a bit lower-overhead than sudo.
This commit is contained in:
Eelco Dolstra 2020-05-15 00:23:28 +02:00
parent 9943fd1a1d
commit b7ddd316f1

View File

@ -343,7 +343,7 @@ in
# Wait for PostgreSQL to be ready to accept connections.
postStart =
''
PSQL="${pkgs.sudo}/bin/sudo -u ${cfg.superUser} psql --port=${toString cfg.port}"
PSQL="${pkgs.utillinux}/bin/runuser -u ${cfg.superUser} -- psql --port=${toString cfg.port}"
while ! $PSQL -d postgres -c "" 2> /dev/null; do
if ! kill -0 "$MAINPID"; then exit 1; fi