Commit Graph

632 Commits

Author SHA1 Message Date
Thomas Gerbet
a9da4c2260
Merge pull request #257504 from SuperSandro2000/postgres-doc
nixos/postgresql: point doc link to current like all others
2023-12-15 00:43:13 +01:00
Sandro Jäckel
4fe5824fc7
nixos/postgresql: take extraPlugins packageset from package option
This allows to reuse the extraPlugins option in other context's for
example an upgrade script.
2023-12-08 14:58:18 +01:00
h7x4
79d3d59f58
treewide: replace mkPackageOptionMD with mkPackageOption 2023-11-30 19:03:14 +01:00
Weijia Wang
feeae486de
Merge pull request #261702 from h7x4/replace-mkoption-with-mkpackageoption
treewide: use `mkPackageOption`
2023-11-30 02:49:30 +01:00
Mario Rodas
3dba8d6fdb
Merge pull request #268634 from tie/redis-restrict-address-families
nixos/redis: loosen systemd address family restrictions
2023-11-27 20:06:29 -05:00
h7x4
0a37316d6c
treewide: use mkPackageOption
This commit replaces a lot of usages of `mkOption` with the package
type, to be `mkPackageOption`, in order to reduce the amount of code.
2023-11-27 01:28:36 +01:00
Sandro Jäckel
515ce669bc
nixos/postgresql: point doc link to current like all others 2023-11-20 14:44:23 +01:00
Sandro
809f926017
nixos/postgresql: fix mentioned settings in ensurePermissions warnings 2023-11-20 14:42:57 +01:00
Ivan Trubach
5c898bec57 nixos/redis: loosen systemd address family restrictions
Do not assume that port and unixSocket are the only options that affect
address families used by Redis. There are other options, e.g. tls-port,
and also clustered setup that are not covered by the declarative
configuration. Instead of trying to selectively restrict unused address
families based on the configuration, limit address families to IP and
Unix sockets and let users lib.mkForce a stricter sandboxing is needed.

See also
https://docs.redis.com/latest/rs/networking/port-configurations/
2023-11-20 07:11:34 +03:00
Ryan Lahfa
ccfe07c316
Merge pull request #266270 from Ma27/postgresql-ownership-15 2023-11-17 18:02:17 +01:00
Herwig Hochleitner
e7c7d97167
nixos/postgresql: document psql 15 changes (#267238)
* nixos/postgresql: document psql 15 changes

* nixos/postgresql: manual heading ids

* nixos/postgresql: reword warning against initialScript

Co-authored-by: Ryan Lahfa <masterancpp@gmail.com>

* nixos/postgresql: wording PERMISSIONS -> PRIVILEGES

Co-authored-by: Ryan Lahfa <masterancpp@gmail.com>

* nixos/postgresql: document intermediate oneshot / service user method

* nixos/postgresql/docs: clarify security benefits of `ensureDBOwnership`

* nixos/postgresql/docs: service type -> serviceConfig.Type

---------

Co-authored-by: Ryan Lahfa <masterancpp@gmail.com>
2023-11-17 16:06:01 +01:00
Raito Bezarius
d57926c0b6 nixos/postgresql: improve the assertions for equality of DB user and DB name
It is hard to figure out which one is offending without the database name.
2023-11-13 17:16:25 +01:00
Raito Bezarius
12797a6a39 nixos/postgresql: restore ensurePermissions and strong-deprecate it
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-13 17:16:25 +01:00
Maximilian Bosch
48459567ae nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
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-13 17:16:25 +01:00
Anthony Roussel
e30f48be94
treewide: fix redirected and broken URLs
Using the script in maintainers/scripts/update-redirected-urls.sh
2023-11-11 10:49:01 +01:00
Maximilian Bosch
1220a4d4dd
postgresql_11: remove
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-30 10:41:16 +01:00
Julien Malka
5237796f2b nixos/ferretdb: fix broken link to documentation 2023-10-23 16:48:31 +00:00
github-actions[bot]
cfc75eec46
Merge master into staging-next 2023-10-20 18:00:54 +00:00
Bjørn Forsman
142074c2a8 nixos: fix bad mkEnableOption descriptions
Fix descriptions that don't account for (1) the "Whether to enable"
prefix or (2) the automatically added trailing dot.
2023-10-20 16:22:40 +01:00
Alyssa Ross
579ae9b989
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/development/python-modules/cirq-core/default.nix
2023-10-16 08:49:23 +00:00
Julien Malka
c54ab7d643 nixos/ferretdb: init 2023-10-16 10:15:30 +02:00
github-actions[bot]
75d4639be3
Merge master into staging-next 2023-10-09 18:00:59 +00:00
Maximilian Bosch
9f1d4b79e3
nixos/postgresql: fix identMap example
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-10-09 17:41:44 +02:00
Jan Tojnar
76a7aa445a Merge branch 'master' into staging-next
Conflicts:
- pkgs/development/python-modules/xdot/default.nix
  between 2f244e3647 and 1a9a257cf7
2023-10-06 23:18:00 +02:00
Artturi
34c738fb3d
Merge pull request #152631 from jonringer/pgmanage-use-package 2023-10-07 00:05:58 +03:00
github-actions[bot]
b7f2311d92
Merge staging-next into staging 2023-09-27 18:01:33 +00:00
Gary Guo
e037977239 postgresql: default to v15 in 23.11 2023-09-27 03:51:06 +02:00
Matthieu Coudron
b53c715e50 services.postgres: add initialScript example 2023-09-18 11:57:58 +02:00
Matthieu Coudron
956a1876aa services.postgresql: add identMap example
to make things clearer
2023-09-18 11:57:58 +02:00
Matthieu Coudron
482619dac7 services.postgres: move the generated statement at the top of the file 2023-09-18 11:57:57 +02:00
happysalada
5ae2b27518 nixos/surrealdb: incorporate beta 10 changes 2023-09-07 08:57:41 +00:00
oddlama
8b5b7def91
nixos/influxdb2: add org, bucket, users and auth provisioning 2023-08-23 14:46:52 +02:00
Nick Cao
a4c6594dcd
nixos/influxdb2: do not load passwordFile and tokenFile when provisioning is disabled 2023-08-18 20:25:53 +08:00
oddlama
b4d718f14a
nixos/influxdb2: add initial setup automation and nixos tests 2023-08-16 14:31:49 +02:00
Matthieu Coudron
6774f3fc04 services.postgresql: fix example 2023-07-27 11:35:55 -05:00
1000101
f63d863fde
nixos/pgbouncer: init (#241578)
Co-authored-by: Marek Mahut <marek.mahut@gmail.com>
2023-07-22 12:49:23 +02:00
Weijia Wang
4b8f7098da foundationdb: cleanup 2023-06-08 14:48:41 +03:00
figsoda
701bcdbead nixos: fix typos 2023-05-19 22:31:04 -04:00
Yureka
97c8817371
nixos/clickhouse: Notify systemd about successful startup (#232443)
https://github.com/ClickHouse/ClickHouse/pull/43400
https://github.com/ClickHouse/ClickHouse/pull/46613
2023-05-19 00:24:20 +02:00
Robert Hensing
2e2f0d28ea nixos: Use checks instead of extraDependencies
... as appropriate.

This drops a few unnecessary store paths from the system closure.
2023-05-11 21:18:38 +02:00
IndeedNotJames
87ccd1a47b
nixos/lldap: init
Co-authored-by: LongerHV <46924944+LongerHV@users.noreply.github.com>
2023-04-29 21:14:25 +02:00
Kerstin Humm
0b0cc93e79
remove myself (erictapen) from packages which I don't use anymore 2023-04-03 17:07:16 +02:00
Sandro
c2ae278eb8
Merge pull request #221851 from Ma27/postgresql-jit-support
postgresql: implement opt-in JIT support
2023-03-29 13:29:30 +02:00
Maximilian Bosch
e2fb651752
nixos/postgresql: fix enableJIT
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-29 08:39:47 +02:00
Maximilian Bosch
43dbeae02d
postgresql: pass through JIT-enabled variant of non-JIT postgres and vice versa
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-03-29 08:39:46 +02:00
Sandro
86053e5ec2
dgraph: use --prefix to prefix PATH
This is more robust in case PATH is empty or otherwise weird.
2023-03-01 13:55:30 +01:00
Maximilian Bosch
3d53723112
Merge pull request #186660 from aopom/clickhouse-conf
Change clickhouse's module conf directory to permit overrides
2023-02-14 15:58:09 +01:00
pennae
0a6e6cf7e6 nixos/manual: render module chapters with nixos-render-docs
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).
2023-01-27 20:07:34 +01:00
pennae
53fc887582 nixos/manual: move "edit the MD file" comments to generated XML 2023-01-10 12:34:37 +01:00
pennae
bf92eaebe4 nixos/manual: generate module chapters with md-to-db.sh 2023-01-10 10:32:00 +01:00