Problem
pg0 fails on NixOS (and any system without /usr/share/zoneinfo) because the bundled PostgreSQL binary from theseus-rs/postgresql-binaries is compiled on Debian with /usr/share/zoneinfo hardcoded.
NixOS stores timezone data at /etc/zoneinfo (symlinked from the Nix store). There is no /usr/share/zoneinfo on a standard NixOS system.
When PostgreSQL starts, it tries to resolve the timezone (e.g., UTC) by looking in /usr/share/zoneinfo and gets a FATAL error:
FATAL: could not find a suitable time zone abbreviations file
or when a client connects and the server processes its startup parameters:
ERROR: invalid value for parameter "TimeZone": "UTC"
DETAIL: /usr/share/zoneinfo: No such file or directory
This causes pg0 start to fail entirely on NixOS systems.
Root Cause
The root cause is in the upstream theseus-rs/postgresql-binaries project — the pre-built binaries are compiled with --with-system-tzdata=/usr/share/zoneinfo. I've also filed an issue there: https://github.com/theseus-rs/postgresql-binaries/issues
Workaround (for NixOS users)
Binary-patch the postgres executable to replace the hardcoded path with the NixOS equivalent:
PG0_POSTGRES=$(find ~/.pg0/installation -name postgres -type f | head -1)
perl -pi -e 's|/usr/share/zoneinfo|/etc/zoneinfo\x00\x00\x00\x00\x00\x00|g' "$PG0_POSTGRES"
The padding with null bytes is required to preserve the binary's size (the path string is the same length).
Suggested Fix in pg0
Until the upstream binaries are fixed, pg0 can mitigate this by explicitly setting timezone = 'UTC' in the configuration HashMap before calling postgresql.start():
// Around line 628 in src/main.rs, where other defaults are set:
configuration.insert("timezone".to_string(), "UTC".to_string());
configuration.insert("log_timezone".to_string(), "UTC".to_string());
These keys are written to postgresql.conf by postgresql_embedded, so PostgreSQL reads them at startup and never falls back to the timezone file lookup path. This is a minimal, low-risk fix that resolves the NixOS failure without requiring binary patches.
Environment
- NixOS (unstable, 2025-04)
- pg0 v0.4.x
- PostgreSQL 18.1 (theseus-rs bundled binary)
- Architecture: x86_64-linux
Problem
pg0 fails on NixOS (and any system without
/usr/share/zoneinfo) because the bundled PostgreSQL binary fromtheseus-rs/postgresql-binariesis compiled on Debian with/usr/share/zoneinfohardcoded.NixOS stores timezone data at
/etc/zoneinfo(symlinked from the Nix store). There is no/usr/share/zoneinfoon a standard NixOS system.When PostgreSQL starts, it tries to resolve the timezone (e.g.,
UTC) by looking in/usr/share/zoneinfoand gets a FATAL error:or when a client connects and the server processes its startup parameters:
This causes
pg0 startto fail entirely on NixOS systems.Root Cause
The root cause is in the upstream
theseus-rs/postgresql-binariesproject — the pre-built binaries are compiled with--with-system-tzdata=/usr/share/zoneinfo. I've also filed an issue there: https://github.com/theseus-rs/postgresql-binaries/issuesWorkaround (for NixOS users)
Binary-patch the
postgresexecutable to replace the hardcoded path with the NixOS equivalent:The padding with null bytes is required to preserve the binary's size (the path string is the same length).
Suggested Fix in pg0
Until the upstream binaries are fixed, pg0 can mitigate this by explicitly setting
timezone = 'UTC'in theconfigurationHashMap before callingpostgresql.start():These keys are written to
postgresql.confbypostgresql_embedded, so PostgreSQL reads them at startup and never falls back to the timezone file lookup path. This is a minimal, low-risk fix that resolves the NixOS failure without requiring binary patches.Environment