How do I imperatively install postgresql with additional packages?

I’ve been installing PostgreSQL using nix-env -iA nixpkgs-latest.postgresql_12. This works well but does not install user contributed modules.

I see the derivation’s definition has a postgresqlWithPackages:
https://github.com/NixOS/nixpkgs/blob/cc6cf0a96a627e678ffc996a8f9d1416200d6c81/pkgs/servers/sql/postgresql/default.nix#L155

How do I consume this using nix-env -i or an equivalent? I’d be happy to use a nix expression as well but don’t understand them very well so often resort to what works.

1 Like

It turns out the extension I needed is already included in the compiled version provided by nix. I just needed to execute the following on the given database:

CREATE EXTENSION citext SCHEMA public;