- Postgresql and PostGIS

I’m attempting to setup my dev env using but ran into complications when installing PostGIS.

The approaches I’ve found online for NixOS/Nix is to use services.postgresql.extraPlugins = with pkgs.postgresql_14.pkgs; [ postgis ];. However, provides services.postgres which doesn’t have any options for extraPlugins.

My nix experience is not deep, is there a way to use PostGIS with Postgres within the context of Or does postgres.nix provided by require updates?

I tried adding postgresql14Packages.postgis / (postgresql_14.withPackages (p: [ p.postgis ] )) to packages but even if PostGIS was installed, creating the extension results in:

ERROR: could not open extension control file "/nix/store/gz287zqdmda0vynmbaf9z3z44r4fvz9r-postgresql-14.7/share/postgresql/extension/postgis.control": No such file or directory


You’re almost there with postgresql_14.withPackages (p: [ p.postgis ] )! Just adding it to your shell with packages is not enough. The trick is to tell the postgres service to use that version of postgres.

The option you’re looking for is services.postgres.package.

services.postgres.package = pkgs.postgresql_14.withPackages (p: [ p.postgis ]);
1 Like