Files
nixpkgs/pkgs/servers/sql/postgresql/default.nix
T
Wolfgang Walther dd5fd6cc22 postgresql: always build with JIT enabled
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.
2025-04-05 20:00:13 +02:00

41 lines
1.2 KiB
Nix

self:
let
# Before removing an EOL major version, make sure to check the versioning policy in:
# <nixpkgs>/nixos/modules/services/databases/postgresql.md
#
# Before removing, make sure to update it to the last minor version - and if only in
# an immediately preceding commit. This allows people relying on that old major version
# for a bit longer to still update up to this commit to at least get the latest minor
# version. In other words: Do not remove the second-to-last minor version from nixpkgs,
# yet. Update first.
versions = {
postgresql_13 = ./13.nix;
postgresql_14 = ./14.nix;
postgresql_15 = ./15.nix;
postgresql_16 = ./16.nix;
postgresql_17 = ./17.nix;
};
mkAttributes =
jitSupport:
self.lib.mapAttrs' (
version: path:
let
attrName = if jitSupport then "${version}_jit" else version;
postgresql = import path { inherit self; };
attrValue = if jitSupport then postgresql.withJIT else postgresql.withoutJIT;
in
self.lib.nameValuePair attrName attrValue
) versions;
libpq = self.callPackage ./libpq.nix { };
in
{
# variations without and with JIT
postgresqlVersions = mkAttributes false;
postgresqlJitVersions = mkAttributes true;
inherit libpq;
}