diff options
author | Raito Bezarius <masterancpp@gmail.com> | 2023-11-13 17:11:06 +0100 |
---|---|---|
committer | Raito Bezarius <masterancpp@gmail.com> | 2023-11-13 17:16:25 +0100 |
commit | d57926c0b62f4cdbaf005f5410a5c795e063aff3 (patch) | |
tree | 0f174731db692c23a2c151faf3aa049dd0d3eff8 /nixos | |
parent | 12797a6a39393c61b00d6e0085eeaffbb1ba1d3c (diff) | |
download | nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.tar nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.tar.gz nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.tar.bz2 nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.tar.lz nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.tar.xz nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.tar.zst nixpkgs-d57926c0b62f4cdbaf005f5410a5c795e063aff3.zip |
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.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/databases/postgresql.nix | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 1c5de85bf2b..a9067d5974a 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -455,19 +455,16 @@ in config = mkIf cfg.enable { - assertions = [ - { - assertion = all - ({ name, ensureDBOwnership, ... }: ensureDBOwnership -> builtins.elem name cfg.ensureDatabases) - cfg.ensureUsers; - message = '' - For each database user defined with `services.postgresql.ensureUsers` and - `ensureDBOwnership = true;`, a database with the same name must be defined - in `services.postgresql.ensureDatabases`. - ''; - } - ]; - + assertions = map ({ name, ensureDBOwnership, ... }: { + assertion = ensureDBOwnership -> builtins.elem name cfg.ensureDatabases; + message = '' + For each database user defined with `services.postgresql.ensureUsers` and + `ensureDBOwnership = true;`, a database with the same name must be defined + in `services.postgresql.ensureDatabases`. + + Offender: ${name} has not been found among databases. + ''; + }) cfg.ensureUsers; # `ensurePermissions` is now deprecated, let's avoid it. warnings = lib.optional (any ({ ensurePermissions, ... }: ensurePermissions != {}) cfg.ensureUsers) " `services.postgresql.*.ensurePermissions` is used in your expressions, |