Compile Postgresql for 16k page size

I’m trying to migrate my homeserver setup to a Raspberry Pi 5. This has only experimental community support. So far, I’m following the recommended community project. It has two versions to build the system. One is basic, only makes it work, the other attempts to make more modifications (nixosSystemFull) by applying a lot of overlays.

The first version works for me. The system builds and operates. But Postgres crashes complaining about the page size. The issue seems to be that it is using jemalloc, which must be compiled for the appropriate page size. nixpkgs sets that to 4k on x86 and 64k on aarch64, but the Pi5 is aarch64 with a page size of 16k.

I suppose this is one of the things that nixosSystemFull would solve, but I’m unable to make that work, as it compiles a lot of stuff locally and quite a few things break in the test phase. I do not have the capacity to debug that.

So, instead, I have attempted (successfully, I believe) to create an overlay for just jemalloc

  nixpkgs.overlays = [
    (self: super: {
      jemalloc = super.jemalloc.overrideAttrs (old: {
        configureFlags = (lib.filter (flag: flag != "--with-lg-page=16") old.configureFlags) ++ [ "--with-lg-page=14" ];
      });
    })
  ];

Checking the store for derivations shows that one with the correct flags has indeed been built (in addition to the leftovers from experimentation). This is not the case for postgresql. Only one derivation there. This is not what I expected. Since it uses jemalloc I’d expect that a rebuild of that should also rebuild postgresql, no?! I’ve briefly looked at the postgresql.nix in nixpkgs but found no mention of “jemalloc” or “alloc” for that matter. So I wonder how that thing is built. Is it compiled from source? Or downloaded somewhere and just patched?

How do I manage to rebuild that with a fitting version of jemalloc for the 16k page size pi 5 kernel?