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>
`config.services.postgresql.package` is now only available when the
PostgreSQL module is actually enabled. If we're not using the local
database, we'll need to fallback to the latest postgresql version, since
we don't know about the remote version.
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
nixos/libeufin: init module
nixos/libeufin(nexus): init submodule
nixos/libeufin(nexus): refactor service
Also added state directory to allow the creation of client ebic keys.
nixos/libeufin: review suggestions
nixos/libeufin: fix nexus service executable
nixos/libeufin: add mkLibeufinModule
nixos/libeufin: fix dbinit service not starting for utils, cleanup
nixos/libeufin: use mkLibeufinModule for nexus
nixos/libeufin: use mkLibeufinModule for bank
nixos/libeufin: add initialAccounts, stateDir options
nixos/libeufin: refactor to make nexus work, cleanup
nixos/libeufin: refactor stateDir, only register accounts on init
nixos/libeufin: explicitly specify psql user
Sometimes the dbinit service fails to find the user.
nixos/libeufin: cleanup stateDir
nixos/libeufin: add openFirewall option; install package
feat: apply review suggestions
Co-authored-by: h7x4 <h7x4@nani.wtf>
style: format code
fix: evaluation errors
fix(libeufin): start main services after dbinit
The main services can start after their databases have been initialized,
it's just that the bank and nexus shouldn't do the initialization at the
same time.
refactor(libeufin): dbinit script
feat: add assertions, remove throw
chore: remove unused code
feat(libeufin): recfactor dbinit service
feat: move libeufin module to services/finance
refactor(libeufin): remove configFile option
refactor(libeufin): use environment.etc for config file
basic config set that makes the service at least start
add secmod helpers and taler-global runtime dir
support for includes
taler denominations
Only enable services if taler is enabled
fix wirewatch service name
use correct permissions for database schema
The current permissions don't work or aren't enough and cause the
wirewatch and closer services to fail.
nixos/libeufin: init module
libeufin: refactor module
libeufin: add main service
nixos/taler: configure settings using options
Works, but can be refactored further
taler: refactor settings options
trim settings defaults to the absolutely necessary ones
nixos/libeufin: refactor and move to separate dir
nixos/libeufin: set defaultText
nixos/libeufin: use getExe
nixos/libeufin-bank: move to own dir
nixos/libeufin: move libeufin related config into its own config file
nixos/libeufin/bank: extract dbinitServiceName into var
nixos/libeufin: move script to ExecStart
nixos/libeufin: fix config file name
nixos/taler: refactor config file
nixos/taler-exchange: grant delete to taler-exchange-aggregator
Would repeatedly attempt to delete in a table where it wasn't allowed to and
cause insane spam in the postgres log.
nixos/taler/exchange: move exchange-specific options to exchange
nixos/taler: move generic taler settings into taler system module
nixos/taler: import exchange in module-list.nix
nixos/taler-exchange: refactor services group name
nixos/taler-exchange: use taler-harness to generate coins
The taler-wallet-cli does not have the deployment subcommand anymore,
but the docs still say that it should be used to generate the keys.
For now, the keys should be generated with taler-harness.
nixos/taler-exchange: add option to enable accounts
nixos/taler: add missing descriptions
nixos/taler(exchange): add description & use getExe'
nixos/taler(merchant): init submodule
nixos/taler: use correct script for db access
nixos/taler: merchant add depositcheck path
nixos/taler: review suggestions
nixos/taler: make runtimeDir into an option, refactor
nixos/taler: init mkTalerModule
nixos/taler: use mkTalerModule for exchange
nixos/taler: exchange fixups
nixos/taler: use mkTalerModule for merchant
nixos/taler: improve how dbInit script is created
nixos/taler: remove exchange enableAccounts option
nixos/taler: explicitly specify psql user
Sometimes the dbinit service fails to find the user.
nixos/taler: add openFirewall option; install package
feat: add assertions, remove throw
feat(taler): use module system instead of functions
Also:
- remove throw from denominateConfig
- rename `utils.nix` to `common.nix`
feat(taler): refactor modules
feat: move taler module to services/finance
refactor(exchange): replace throw with assert
refactor(exchange,merchant): settings options
fix(taler): manpage URLs
fix(exchange): public key assert
refactor(taler): use configFile
feat(taler): include component configs directly
Makes services detect config changes better.
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
these changes were generated with nixq 0.0.2, by running
nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix
two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.
Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
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
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.
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.