Devenv.sh - Postgresql and PostGIS

I’m attempting to setup my dev env using devenv.sh 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, devenv.sh 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 devenv.sh? Or does postgres.nix provided by devenv.sh 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

Thanks!

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