summary refs log tree commit diff
path: root/nixos/modules/services/databases/postgresql.nix
AgeCommit message (Collapse)AuthorFilesLines
2023-11-20nixos/postgresql: fix mentioned settings in ensurePermissions warningsSandro1-2/+2
2023-11-13nixos/postgresql: improve the assertions for equality of DB user and DB nameRaito Bezarius1-13/+10
It is hard to figure out which one is offending without the database name.
2023-11-13nixos/postgresql: restore `ensurePermissions` and strong-deprecate itRaito Bezarius1-1/+45
As it is technically a breaking change, we should at least make a strong deprecation of `ensurePermissions` and leave it in the broken state it is, for out of tree users. We give them a 6 months notice to migrate away by doing so, which is honest. In the meantime, we forbid usage of `ensurePermissions` inside of nixpkgs.
2023-11-13nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15Maximilian Bosch1-35/+30
Closes #216989 First of all, a bit of context: in PostgreSQL, newly created users don't have the CREATE privilege on the public schema of a database even with `ALL PRIVILEGES` granted via `ensurePermissions` which is how most of the DB users are currently set up "declaratively"[1]. This means e.g. a freshly deployed Nextcloud service will break early because Nextcloud itself cannot CREATE any tables in the public schema anymore. The other issue here is that `ensurePermissions` is a mere hack. It's effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how a value is substituted in a query. You'd have to parse a subset of SQL to actually know which object are permissions granted to for a user). After analyzing the existing modules I realized that in every case with a single exception[2] the UNIX system user is equal to the db user is equal to the db name and I don't see a compelling reason why people would change that in 99% of the cases. In fact, some modules would even break if you'd change that because the declarations of the system user & the db user are mixed up[3]. So I decided to go with something new which restricts the ways to use `ensure*` options rather than expanding those[4]. Effectively this means that * The DB user _must_ be equal to the DB name. * Permissions are granted via `ensureDBOwnerhip` for an attribute-set in `ensureUsers`. That way, the user is actually the owner and can perform `CREATE`. * For such a postgres user, a database must be declared in `ensureDatabases`. For anything else, a custom state management should be implemented. This can either be `initialScript`, doing it manual, outside of the module or by implementing proper state management for postgresql[5], but the current state of `ensure*` isn't even declarative, but a convergent tool which is what Nix actually claims to _not_ do. Regarding existing setups: there are effectively two options: * Leave everything as-is (assuming that system user == db user == db name): then the DB user will automatically become the DB owner and everything else stays the same. * Drop the `createDatabase = true;` declarations: nothing will change because a removal of `ensure*` statements is ignored, so it doesn't matter at all whether this option is kept after the first deploy (and later on you'd usually restore from backups anyways). The DB user isn't the owner of the DB then, but for an existing setup this is irrelevant because CREATE on the public schema isn't revoked from existing users (only not granted for new users). [1] not really declarative though because removals of these statements are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467 [2] `services.invidious`: I removed the `ensure*` part temporarily because it IMHO falls into the category "manage the state on your own" (see the commit message). See also https://github.com/NixOS/nixpkgs/pull/265857 [3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";` [4] As opposed to other changes that are considered a potential fix, but also add more things like collation for DBs or passwords that are _never_ touched again when changing those. [5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-11treewide: fix redirected and broken URLsAnthony Roussel1-1/+1
Using the script in maintainers/scripts/update-redirected-urls.sh
2023-10-30postgresql_11: removeMaximilian Bosch1-5/+5
As described in the release lifecycle docs from postgresql[1], v11 will stop receiving fixes as of Nov 9 2023. This means it's EOL throughout the entire lifetime of 23.11, so let's drop it now. A lot of examples are also referencing postgresql_11. Where it's sensible, use postgresql_15 as example now to avoid confusion. This is also handy because the LLVM 16 fix for postgresql is not available for postgresql 11 ;-) [1] https://www.postgresql.org/support/versioning/
2023-10-09Merge master into staging-nextgithub-actions[bot]1-1/+1
2023-10-09nixos/postgresql: fix `identMap` exampleMaximilian Bosch1-1/+1
This was causing the following warning before when building the manual: warning: literalExample is deprecated, use literalExpression instead, or use literalMD for a non-Nix description. Rather than using `literalExpression`, nothing is used. This option expects a string and the example is a string, no special handling required. Both `literalExample` from the docbook ages and `literalExpression` now are only required if the example is a Nix expression rather than a value of the option's type.
2023-09-27Merge staging-next into staginggithub-actions[bot]1-6/+16
2023-09-27postgresql: default to v15 in 23.11Gary Guo1-1/+2
2023-09-18services.postgres: add initialScript exampleMatthieu Coudron1-0/+5
2023-09-18services.postgresql: add identMap exampleMatthieu Coudron1-3/+5
to make things clearer
2023-09-18services.postgres: move the generated statement at the top of the fileMatthieu Coudron1-3/+6
2023-07-27services.postgresql: fix exampleMatthieu Coudron1-2/+2
2023-05-11nixos: Use checks instead of extraDependenciesRobert Hensing1-1/+1
... as appropriate. This drops a few unnecessary store paths from the system closure.
2023-03-29nixos/postgresql: fix enableJITMaximilian Bosch1-2/+11
Make sure that JIT is actually available when using services.postgresql = { enable = true; enableJIT = true; package = pkgs.postgresql_15; }; The current behavior is counter-intuitive because the docs state that `enableJIT = true;` is sufficient even though it wasn't in that case because the declared package doesn't have the LLVM dependency. Fixed by using `package.withJIT` if `enableJIT = true;` and `package.jitSupport` is `false`. Also updated the postgresql-jit test to test for that case.
2023-03-29postgresql: pass through JIT-enabled variant of non-JIT postgres and vice versaMaximilian Bosch1-5/+9
This is useful if your postgresql version is dependant on `system.stateVersion` and not pinned down manually. Then it's not necessary to find out which version exactly is in use and define `package` manually, but just stay with what NixOS provides as default: $ nix-instantiate -A postgresql /nix/store/82fzmb77mz2b787dgj7mn4a8i4f6l6sn-postgresql-14.7.drv $ nix-instantiate -A postgresql_jit /nix/store/qsjkb72fcrrfpsszrwbsi9q9wgp39m50-postgresql-14.7.drv $ nix-instantiate -A postgresql.withJIT /nix/store/qsjkb72fcrrfpsszrwbsi9q9wgp39m50-postgresql-14.7.drv $ nix-instantiate -A postgresql.withJIT.withoutJIT /nix/store/82fzmb77mz2b787dgj7mn4a8i4f6l6sn-postgresql-14.7.drv I.e. you can use postgresql with JIT (for complex queries only[1]) like this: services.postgresql = { enable = true; enableJIT = true; }; Performing a new override instead of re-using the `_jit`-variants for that has the nice property that overlays for the original package apply to the JIT-enabled variant, i.e. with import ./. { overlays = [ (self: super: { postgresql = super.postgresql.overrideAttrs (_: { fnord = "snens"; }); }) ]; }; postgresql.withJIT.fnord still gives the string `snens` whereas `postgresql_jit` doesn't have the attribute `fnord` in its derivation. [1] https://www.postgresql.org/docs/current/runtime-config-query.html#GUC-JIT-ABOVE-COST
2023-01-27nixos/manual: render module chapters with nixos-render-docspennae1-1/+1
this converts meta.doc into an md pointer, not an xml pointer. since we no longer need xml for manual chapters we can also remove support for manual chapters from md-to-db.sh since pandoc converts smart quotes to docbook quote elements and our nixos-render-docs does not we lose this distinction in the rendered output. that's probably not that bad, our stylesheet didn't make use of this anyway (and pre-23.05 versions of the chapters didn't use quote elements either). also updates the nixpkgs manual to clarify that option docs support all extensions (although it doesn't support headings at all, so heading anchors don't work by extension).
2022-12-02Merge remote-tracking branch 'upstream/master' into allow-configuration-of-rolesRobert Hensing1-36/+36
2022-12-01treewide: switch to port type for nixos modulesDaniel Nagy1-1/+1
2022-11-28Update nixos/modules/services/databases/postgresql.nixJonathan Lorimer1-1/+1
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-11-28Add declarative role config to postgres.serviceJonathan Lorimer1-6/+172
remove trailing whitespace switch docs to markdown use mdDoc remove trailing whitespace get rid of double space add tests and update options to use submodule remove whitespace remove whitespace use mdDoc remove whitespace make default a no-op make ALTER ROLE a single sql statement document null case
2022-08-31nixos/*: convert options with admonitions to MDpennae1-7/+7
rendering changes only slightly, most changes are in spacing.
2022-08-31nixos/*: convert internal option descriptions to MDpennae1-1/+1
we'll have to do it eventually, may as well be now.
2022-08-31nixos/*: automatically convert option descriptionspennae1-1/+1
conversions were done using https://github.com/pennae/nix-doc-munge using (probably) rev f34e145 running nix-doc-munge nixos/**/*.nix nix-doc-munge --import nixos/**/*.nix the tool ensures that only changes that could affect the generated manual *but don't* are committed, other changes require manual review and are discarded.
2022-08-19nixos/*: automatically convert option docspennae1-3/+3
2022-08-19nixos/postgresql: replace <function> with <literal>pennae1-1/+1
there's only this one use, we can live with the tiny rendering change.
2022-08-03nixos/*: automatically convert option docs to MDpennae1-3/+3
once again using nix-doc-munge (https://github.com/pennae/nix-doc-munge/commit/69d080323ae27c0d8da3967c62b925a9aedb2828)
2022-08-03nixos/*: normalize link formatpennae1-2/+1
make (almost) all links appear on only a single line, with no unnecessary whitespace, using double quotes for attributes. this lets us automatically convert them to markdown easily. the few remaining links are extremely long link in a gnome module, we'll come back to those at a later date.
2022-08-03nixos/*: replace <code> in option docs with <literal>pennae1-1/+1
markdown can't represent the difference without another extension and both the html manual and the manpage render them the same, so keeping the distinction is not very useful on its own. with the distinction removed we can automatically convert many options that use <code> tags to markdown. the manpage remains unchanged, html manual does not render differently (but class names on code tags do change from "code" to "literal").
2022-07-30treewide: automatically md-convert option descriptionspennae1-18/+18
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
2022-05-03nixos/postgresql: use postgres 14 for 22.05Ivan Kozik1-1/+2
postgresql: alias to postgresql_14
2021-12-03postgresql_9_6: dropajs1241-3/+5
2021-10-04nixos/doc: clean up defaults and examplesNaïm Favier1-6/+6
2021-07-24nixos/postgresql: use postgres 13 for 21.11 (#131018)Yuka1-1/+2
Co-authored-by: Kim Lindberger <kim.lindberger@gmail.com>
2021-05-17nixos/postgresql: fix description of ensureUsers.ensurePermissionsRichard Marko1-1/+1
`attrName` and `attrValue` are now in correct order.
2021-04-01postgresql_9_5: dropMario Rodas1-2/+1
PostgreSQL 9.5 has reached EOL on February 11, 2021. See https://www.postgresql.org/support/versioning/
2021-04-10services.postgresql: Improve example clarityJoe Hermaszewski1-1/+1
Although the quotes here aren't necessary, they may be if a user cargo-cults this example with a database name with hyphens (or other "unusual" characters).
2021-04-02Merge pull request #92929 from symphorien/postgresql-check-config-fileGuillaume Girol1-2/+15
nixos/postgresql: check config file syntax at build time
2020-10-31nixos/postgresql: fix inaccurate docs for authentication (#97622)Jade1-5/+10
* nixos/postgresql: fix inaccurate docs for authentication We actually use peer authentication, then md5 based authentication. trust is not used. * Use a link for mkForce docs Co-authored-by: aszlig <aszlig@redmoonstudios.org> Co-authored-by: lf- <lf-@users.noreply.github.com> Co-authored-by: aszlig <aszlig@redmoonstudios.org>
2020-09-20nixos/postgresql: check config file syntax at build timeSymphorien Gibol1-2/+15
2020-08-26nixos/postgresql: replace extraConfig option with settings optionAaron Andersen1-14/+42
2020-08-15nixos/postgresql: move ExecStartPost into postStartAaron Andersen1-34/+29
2020-08-15nixos/postgresql: run ExecStartPost as an unprivileged userAaron Andersen1-6/+7
2020-08-06nixos/postgresql: fix setup scriptPascal Bach1-2/+2
The missing () caused parts of the escripts to be added to the ExecStartPost line instead of inside the script. This caused postgresql start to fail under certain conditions.
2020-08-05nixos/postgresql: replace deprecated usage of PermissionsStartOnlyAaron Andersen1-39/+40
2020-08-05nixos/postgresql: conditionally provision data directory with StateDirectoryAaron Andersen1-11/+13
2020-08-05nixos/postgresql: use a standard default value for dataDirAaron Andersen1-5/+3
2020-05-15postgresql: Use runuser instead of sudoEelco Dolstra1-1/+1
Currently, sudo doesn't work in a NixOS container running inside a Nix build, because Nix's seccomp filter doesn't allow setuid programs. In any case, runuser is a bit lower-overhead than sudo.
2020-05-14Merge pull request #87219 from serokell/kirelagin/postgres-no-timeLinus Heckemann1-0/+12
postgres: Do not log timestamp