Moves the function to a separate file and makes it callPackage-able. Now
that buildEnv also supports finalAttrs, the finalPackage construct can
also be rewritten that way.
This gives us clear separation of concern between the package builder in
generic.nix and wrapper.nix.
Before this change, we would return:
- The postgresql derivation itself from `postgresql.withoutJIT`,
- A wrapper without any extensions at all, from
`postgresql_jit.withoutJIT`.
This changes makes it that every call to `.withJIT` and `.withoutJIT`
returns a wrapper and never the base derivation. More consistent and
easier to reason about.
This breaks again and again - and upstream is not really going to
support it anyway. It never fully worked - and the important thing is to
be able to build `pkgsStatic.libpq` anyway, which works independently of
the server package.
This commit was created by a combination of scripts and tools:
- an ast-grep script to prefix things in meta with `lib.`,
- a modified nixf-diagnose / nixf combination to remove unused `with
lib;`, and
- regular nixfmt.
Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
After a recent update of libxml2 the build fails with
/nix/store/casz7al9kpkg52sn156h6slqijwkybqj-libxml2-2.15.0-bin/bin/xmllint --nonet --path . --path . --output postgres-full.xml --noent --valid postgres.sgml
ref/pg_combinebackup.sgml:287: validity error : standalone: normalization of attribute linkend on xref by external subset declaration
state of the cluster using <xref linkend="app-pgchecksums "/> is
Reported in #448752 (not closing on purpose since the issue is actually
about another problem).
While the functionality itself works, it is broken inside the sandbox
since NUMA information is exposed via sysfs which is not available in
the sandbox.
This allows `postgresql.withPackages` to easily override the paths to
the default and man outputs for `pg_config`. It avoids all
`buildEnv`-dev-output hackery, which it didn't properly support, and
separates the logic cleanly.
Follows up on #426118
Still produces a broken test:
diff -U3 /build/source/src/test/regress/expected/numa.out /build/source/src/test/regress/results/numa.out
--- /build/source/src/test/regress/expected/numa.out 1970-01-01 00:00:01.000000000 +0000
+++ /build/source/src/test/regress/results/numa.out 2025-07-19 08:44:02.793368816 +0000
@@ -6,8 +6,4 @@
-- switch to superuser
\c -
SELECT COUNT(*) >= 0 AS ok FROM pg_shmem_allocations_numa;
- ok
-----
- t
-(1 row)
-
+ERROR: invalid NUMA node id outside of allowed range [0, 0]: 1
Previously, pg_config would report the paths of the underlying
postgresql derivation and not the paths of the buildEnv that
postgresql.withPackages creates.
That's a problem when users of pg_config use it to find PostgreSQL's
sharedir, in which they'd like to find the extensions added via
withPackages. Those are only linked into the created buildEnv, but not
available in the postgresql derivation.
By providing our own nix-support/pg_config.env file, we can swap out
those paths. We also do the same for the -man output, because this
output is linked into buildEnv as well. Other paths, which are not
available in the buildEnv environment, will still link to the original
postgresql derivation. Win-win!
This can be observed when building
haskellPackages.postgresql-libpq-pkgconfig. This is currently pinned to
postgresql_16 in pkgsStatic, but when unpinning it, it will fail with
the mentioned error on master. With this fix, it successfully builds
with postgresql_17 / libpq.
This changes the build to always enable JIT - but to only enable it at
run-time, when required. This keeps the runtime closure small without
JIT, but allows enabling it without a rebuild. We can do this, because
JIT is actually built as a shared module, which is loaded at run-time.
We put it into a -jit output and only link it into the environment when
requested.
Under the hood, this uses withPackages and adds the "JIT package" -
thus, to be able to use withPackages on top of that, we also need to be
able to apply withPackages repeatedly.
This cuts down the number of NixOS tests in half, because we don't need
to run it for every version with and without JIT anymore. There really
is no point in running everything with llvmjit.so in place, when the
queries are not making use of it anyway.
Also, we only need to build each extension once and not twice, further
reducing the number of rebuilds required for PRs touching postgresql.