Adding pg_background extension to PostgreSQL

Hi All,

I am trying to add GitHub - vibhorkum/pg_background: pg_background to my PostgreSQL in dev shell. I’ve created a pg_background.nix file copying one of the Pg extensions in Nix packages repository, but I don’t know how to properly configure an overlay so that I can use postgresql18.withPackagesto install it.

Tried to follow How to override a postgresql extension? found here but could not get it working.

Anybody has any idea how to do that?

Thanks!

By copying an existing extension from Nixpkgs, you are most likely using postgresqlBuildExtension, which is not available outside the postgresqlPackages scope. This scope does not support .override, though, so this won’t work, yet.

There’s an issue in Nixpkgs here: postgresqlPackages: `override` is not supported · Issue #401819 · NixOS/nixpkgs · GitHub - also see the comment I left there about the options.

TLDR:

  • Either build the extension without postgresqlBuildExtension - and then add it manually to withPackages, or
  • Upstream the extension addition and request me for review. I’m happy to review new PG extensions and iterate on them quickly :slight_smile:
1 Like

Thanks @wolfgangwalther - I’ve raised a PR postgresqlPackages.pg_background: init at 1.5 by mkleczek · Pull Request #473630 · NixOS/nixpkgs · GitHub. Bear with me though - I am a complete newbie and I am not sure what tests are needed and how to perform them.