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
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?
I ended up copy-pastaing postgres build, I’m sure there is a way to do it better but I copied nixpkgs entire pkgs/servers/sql/postgresql/ directory then making my overlay:
diff --git a/pkgs/postgresql/ext/pgvecto-rs/package.nix b/pkgs/postgresql/ext/pgvecto-rs/package.nix
index b78d948..ca55431 100644
--- a/pkgs/postgresql/ext/pgvecto-rs/package.nix
+++ b/pkgs/postgresql/ext/pgvecto-rs/package.nix
@@ -73,6 +73,8 @@ in
# Bypass rust nightly features not being available on rust stable
RUSTC_BOOTSTRAP = 1;
+
+ JEMALLOC_SYS_WITH_LG_PAGE = "14";
};
# This crate does not have the "pg_test" feature
probably need to submit a patch to upstream to allow this to be overriden at the top level in postgres package