[PATCH]: services: databases: add option to specify UID / GID for the postgres user

  • Done
  • quality assurance status badge
2 participants
  • Ludovic Courtès
  • Martin Baulig
Submitted by
Martin Baulig
Martin Baulig wrote on 22 Jul 2023 02:27
(name . guix-patches@gnu.org)(address . guix-patches@gnu.org)

This is my first contribution to GNU Guix, and I hope this patch is in the correct format.

Attached is a small patch to gnu/services/databases.scm that adds an option to explicitly
specify the UID / GID for the postgres user, as well as an option not to create the service
account at all.

I added some documentation as well and provided a detailed reasoning and background
in the commit message.

Hope this is useful and looking forward to hearing back to you,

Attachment: file
Ludovic Courtès wrote on 16 Aug 2023 22:44
(name . Martin Baulig)(address . martin@baulig.is)(address . 64786-done@debbugs.gnu.org)
Hi Martin,

Martin Baulig <martin@baulig.is> skribis:

Toggle quote (27 lines)
> From ae2534f6cc8611483a11f7a934777a03bd194a27 Mon Sep 17 00:00:00 2001
> From: Martin Baulig <martin@baulig.is>
> Date: Mon, 17 Jul 2023 18:13:42 -0400
> Subject: [PATCH] services: databases: Add option to specify UID / GID for
> postgres user.
> Add 'createAccount?', 'uid' and 'gid' to <postgresql-configuation>.
> Unlike other system daemons, the PostgreSQL data directory is typically
> meant to persist across 'guix system reconfigure' and once created, you
> don't want it's UID or GID to change anymore.
> Furthermore, if you want to place the data directory on a network share
> and use NFSv4 with idmap, then the 'postgres' user must exist when the
> 'rpc.idmapd' daemon is launched; prior to mounting the share. And it
> needs to be possible to mount the share without configuring PostgreSQL.
> With NFSv3, the UID and GID typically needs to match those on the
> server.
> The added options allow for both of these scenarios:
> You can either create the user in (operating-system (users)) completely
> independently of the 'postgresql-service-type' (for instance to get your
> NFS setup working first prior to configuring your databases) - or "pin"
> it's UID / GID values.

This look very useful. I wish this situation could be handled in a more
automatic way somehow, but at least this patch lets admins handle it
“manually” as you write, and that’s a great improvement.

I expanded the commit log to match the conventions as noted in
and applied it.

Thank you, and welcome!