39 Commits

Author SHA1 Message Date
Wolfgang Walther e5699f2308 postgresqlPackages.plv8: drop
`plv8` depends on the outdated NodeJS 20. Upstream waits for v8-cmake to
make a move (https://github.com/plv8/plv8/issues/610), but that project
has been inactive for a bit more than a year.

Even when allowing the insecure nodejs20, the package fails to build.
Insecure and broken - we might as well drop it.
2026-06-13 11:53:42 +02:00
r-vdp ff254c7120 nixos/tests/postgresql: migrate from handleTest to runTest
See: https://github.com/NixOS/nixpkgs/issues/386873
2026-01-28 10:04:44 +01:00
r-vdp 1926fb1b9b nixos/tests/postgresql: replace activation scripts by systemd services
See https://github.com/NixOS/nixpkgs/issues/475305
2026-01-27 11:36:25 +01:00
Leona Maroni d54a686bba treewide: Take over maintainership from the flyingcircus team
The flyingcircus team was dissolved as it's an external team.
We (osnyx and me) take over maintainersip as persons.
2026-01-12 15:48:18 +01:00
Wolfgang Walther 0a5456c067 teams/flyingcircus: drop 2026-01-10 21:57:59 +01:00
Mikilio 3c589f7550 nixos/postgresql: add freeformType to ensureClauses option
This commit adds a freeform type to accomodate for new options to use
with ALTER ROLE.
It also will perform extra checking and conversion for options with
parameters.
Converts option names into upper case with space instead of underscore.
2025-12-26 11:55:53 +01:00
Maximilian Bosch a6bbde82dc nixos/tests/postgresql: switch to unittest-style assertions
This has the benefit that we don't have to write ad-hoc code anymore for
showing the different, `unittest` takes care of that for us already.
2025-12-22 12:56:11 +01:00
Bouke van der Bijl b67248cd59 nixos/postgresql: don't create postgresql-setup if no setup is needed
Also add postgresql replication test

Fixes #469859
2025-12-22 11:01:11 +01:00
Wolfgang Walther 91a8fee3aa treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
Leona Maroni 543d5d030f {pg-dump-anon,postgresql.pkgs.anonymizer}: 1.3.2 -> 2.4.1 (#445784) 2025-09-25 08:26:43 +00:00
Wolfgang Walther f797efcfe8 nixosTests.postgresql.anonymizer.postgresql_18: fix test
The test for the latest PostgreSQL version will always fail while
`postgresql` doesn't point to that, yet.

That's because `pg_dump` can only connect to older versions, so the
`postgresql` package that `pg-dump-anon` uses always needs to use the
very latest version.
2025-09-24 14:32:57 +02:00
Wolfgang Walther df837de00a nixosTests.postgresql.anonymizer: silence warning 2025-09-24 13:58:12 +02:00
Wolfgang Walther 4182de0892 {pg-dump-anon,postgresql.pkgs.anonymizer}: 1.3.2 -> 2.4.1
Release Notes:
https://gitlab.com/dalibo/postgresql_anonymizer/-/blob/latest/CHANGELOG.md?ref_type=heads#20250919--241---minor-bug-fixes
2025-09-24 13:57:41 +02:00
Sefa Eyeoglu 82d2631e1c nixos/postgresql-backup: add pgdumpAllOptions
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2025-08-29 22:22:11 +02:00
Wolfgang Walther 87e1134406 postgresql.tests.postgresql.postgresql-backup-all: fix random dump
The new `\restrict` migitation creates random keys in the dump file by
default, which breaks a before/after test for the backup module. By
making the restrict key reproducible, the test passes again.
2025-08-23 21:13:09 +02:00
Maximilian Bosch 6ae194e419 nixos/postgresql: set Restart=always for postgresql.service
...including a slightly more careful config around restarts, i.e.

* We have intervals of 5 seconds between restarts instead of 100ms.

* If we exceed 5 start attempts in 5*120s (with 120s being the timeout),
  start job gets rate-limited and thus aborted. Do note that there are
  at most 5 start attempts allowed in ~625s by default. If the startup
  fails very quickly, either wait until the rate-limit is over or reset
  the counter using `systemctl reset-failed postgresql.service`.

* The interval of 625s (plus 5s of buffer) are automatically derived
  from RestartSec & TimeoutSec. Changing either will also affect
  StartLimitIntervalSec unless overridden with `mkForce`.
2025-07-26 19:11:54 +02:00
Wolfgang Walther 41c5662cbe nixos/postgresql: move postStart into separate unit
This avoids restarting the postgresql server, when only ensureDatabases
or ensureUsers have been changed. It will also allow to properly wait
for recovery to finish later.

To wait for "postgresql is ready" in other services, we now provide a
postgresql.target.

Resolves #400018

Co-authored-by: Marcel <me@m4rc3l.de>
2025-06-24 15:26:47 +02:00
WilliButz 356d4fc91c treewide: remove myself from maintainers
This removes maintainer entries which haven't reflected reality for a
while, mostly due to a change in focus towards other topics.
2025-06-11 17:39:42 +02:00
Wolfgang Walther 3d29b7d3a2 nixos/postgresql: improve local peer authentication with default map
This allows to easily map allowed database roles to system users.
2025-05-11 10:24:21 +02:00
K900 df4847ebd5 Merge remote-tracking branch 'origin/staging-next' into staging 2025-04-22 21:21:57 +03:00
Wolfgang Walther 722e4bf4ff postgresqlPackages.pgvecto-rs: move test from VM to postgresqlTestExtension 2025-04-21 12:56:19 +02:00
Wolfgang Walther 3af009b416 postgresqlPackages.tsja: move test from VM to postgresqlTestExtension 2025-04-21 12:36:26 +02:00
Wolfgang Walther e06b22b254 postgresqlPackages.timescaledb: move test from VM to postgresqlTestExtension 2025-04-21 12:36:14 +02:00
Wolfgang Walther 6cc89cd16e postgresqlPackages.citus: move test from VM to postgresqlTestExtension 2025-04-21 12:35:57 +02:00
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
Wolfgang Walther cd972edfe4 postgresqlJitPackages.plv8: unbreak
This was originally marked as broken, because plv8 hardcoded gcc in its
Makefile. This has been resolved upstream in the meantime, so it builds
fine.
2025-04-05 13:41:30 +02:00
Diogo Correia f875b09f1e pgvecto-rs: update links in comments to new website
The pgvecto.rs domain is no longer registered.
2025-03-24 14:22:42 +00:00
Julien Langlois 37372eb227 nixos/postgresql/citus: fix syscall filter and add test 2025-02-09 18:07:27 -05:00
Maximilian Bosch eb96c8dc5b postgresql: refactor postgresqlVersions attribute & tests
Every postgresql testcase essentially does the following things:

* Filter `postgresqlVersions` for server packages
* Filter postgresql server packages for suitable ones (i.e. extensions
  must support the given version)
* Generate an attribute-set of testcases

The first item became necessary in
7ab1e88833 given that
`postgresql/default.nix` now exposes JIT and non-JIT servers AND a
`libpq` that is not suitable for the tests here.

This changes restructures this a little bit, i.e.:

* Having an attribute-set that contains a bunch of postgresql servers
  and a single client package seems odd (and the sole consumer of
  `postgresqlVersions` in nixpkgs, the test suite, has to take that into
  account). Hence, postgresql's default.nix now provides `libpq` (the client)
  and a `postgresqlVersions` attribute with all supported JIT and non-JIT
  variants of postgresql.

* Each test-case gets a third argument, a function called `genTests`:
  this function sets `recurseForDerivations = true;` and generates an
  attribute-set of tests for each postgresql version given a function
  that returns a testcase or multiple test-cases (`makeTestFor`). The
  argument to `makeTestFor` is a postgresql server package.

  This function also accepts a filter predicate that is passed against
  `filterAttrs` to remove postgresql server packages that are not
  suitable for the test (e.g. because the version isn't supported by the
  extension to test).

I checked by making sure that the `.drv` doesn't change on staging with
this change on top for postgresq, postgresql-jit,
postgresql-wal-receiver, postgresql-tls-client-cert, anonymizer, pgjwt,
pgvecto-rs, timescaledb, tsja and wal2json.
2025-01-26 21:58:57 +01:00
Maximilian Bosch 7ab1e88833 nixosTests.postgresql.*: fix eval
The `libpq` attribute from `postgresqlVersions` doesn't have a `pkgs`
attribute with extensions in it. Filtering for postgresql server
packages only fixes the problem.

Reported in https://github.com/NixOS/nixpkgs/pull/359659#issuecomment-2601045449
2025-01-20 14:29:01 +01:00
euxane 1dabc1f584 maintainers: rename pacien -> euxane, update details 2024-12-21 21:20:22 +01:00
Maximilian Bosch 68d9643388 nixos/tests/postgresql: test plv8 hardening on non-JIT variants only
PostgreSQL with JIT support enabled doesn't work with plv8. Hence, we'd
get an evaluation failure for each
`nixosTests.postgresql.postgresql.postgresql_jit_X`.

This should be restructured in the future (less VM tests for custom
extensions, but a single VM test for this case to cover). For now, we
should get this fix out and this is a good-enough approach.
2024-11-16 21:16:06 +01:00
Martin Weinelt e198536d26 nixosTests.postgresql: test hardening gets relaxed
The plv8 plugin requires access to pkey syscalls. The execution will
crash hard when it is not allowed by the syscall filter.

Co-Authored-By: Jan Tojnar <jtojnar@gmail.com>
2024-11-16 17:29:34 +01:00
Martin Weinelt 223a6c6ed0 nixos/postgresql: rename extraPlugins to extensions
This is the upstream lingo, and it makes everything slightly less
confusing.
2024-11-16 14:46:16 +01:00
Wolfgang Walther 9486472352 nixosTests.postgresql: run tests with JIT as well
This was intended for quite some time already, but ever since enableJIT
was changed to be the source of truth of JIT-iness for the PostgreSQL
module, this hasn't worked for the tests anymore.
2024-11-12 21:04:41 +01:00
Wolfgang Walther 45cef36e39 nixosTests.postgresql: run nixfmt
Because with as many changes as in here anybody working on those test
files will have merge conflicts anyway.
2024-11-09 18:24:52 +01:00
Wolfgang Walther 128244b598 nixosTests.postgresql: use a common pattern throughout all tests
Avoiding "with", using the same names and basic structure in each test.

Consistency is key!
2024-11-09 18:24:52 +01:00
Wolfgang Walther 9035573855 nixosTests.postgresql: move all postgresql related nixosTests into one folder
This makes it possible to run all those tests at once by building
nixosTests.postgresql and allow a simple entry to ci/OWNERS for all
tests.
2024-11-09 18:24:52 +01:00
Euan Kemp 554ec1c0f0 nixos/tests: add postgresql wal2json test
This test should ensure wal2json functions.
I'm planning to upgrade wal2json, so it seems nice to have a test here.

It passes on my machine.
2024-09-14 05:17:49 +00:00