How to enable PostgreSQL support in Dovecot?

Dovecot in NixOS’ nixpkgs does not seem to have been compiled with PostgreSQL support.

On NixOS

# /run/current-system/sw/bin/dovecot  --build-options
Build options: ioloop=epoll notify=inotify openssl io_block_size=8192
SQL drivers: sqlite
...

On Debian

# dovecot --build-options
Build options: ioloop=epoll notify=inotify openssl io_block_size=8192                              
SQL driver plugins: mysql postgresql sqlite
...

None of the options in services.dovecot2 seem to be related to this.

How should I proceed? My goal is for Dovecot to be able to read users from a PostgreSQL db.

After some investigation I added an overlay for the dovecot package and explicitly activate the withPgSQL option to build it with PostgreSQL support.

I added the following in my configuration.nix. For cohesion, I suggest the position above services.dovecot2 = {.

  nixpkgs.overlays = [
     (self: super: {
       dovecot = super.dovecot.override { withPgSQL = true; };
     })
   ];

Would appreciate an approval from an experienced user or the suggestion of a more idiomatic solution, if one exists.

1 Like