summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/services/databases/postgresql.nix65
-rw-r--r--nixos/modules/services/development/zammad.nix4
-rw-r--r--nixos/modules/services/finance/odoo.nix2
-rw-r--r--nixos/modules/services/mail/listmonk.nix2
-rw-r--r--nixos/modules/services/mail/roundcube.nix14
-rw-r--r--nixos/modules/services/mail/sympa.nix10
-rw-r--r--nixos/modules/services/matrix/matrix-sliding-sync.nix4
-rw-r--r--nixos/modules/services/matrix/mautrix-facebook.nix4
-rw-r--r--nixos/modules/services/misc/atuin.nix4
-rw-r--r--nixos/modules/services/misc/forgejo.nix10
-rw-r--r--nixos/modules/services/misc/gitea.nix10
-rw-r--r--nixos/modules/services/misc/redmine.nix4
-rw-r--r--nixos/modules/services/misc/sourcehut/service.nix11
-rw-r--r--nixos/modules/services/monitoring/zabbix-proxy.nix4
-rw-r--r--nixos/modules/services/monitoring/zabbix-server.nix4
-rw-r--r--nixos/modules/services/security/hockeypuck.nix2
-rw-r--r--nixos/modules/services/web-apps/coder.nix10
-rw-r--r--nixos/modules/services/web-apps/gotosocial.nix4
-rw-r--r--nixos/modules/services/web-apps/invidious.nix6
-rw-r--r--nixos/modules/services/web-apps/lemmy.nix2
-rw-r--r--nixos/modules/services/web-apps/mastodon.nix6
-rw-r--r--nixos/modules/services/web-apps/mediawiki.nix4
-rw-r--r--nixos/modules/services/web-apps/miniflux.nix17
-rw-r--r--nixos/modules/services/web-apps/mobilizon.nix10
-rw-r--r--nixos/modules/services/web-apps/moodle.nix4
-rw-r--r--nixos/modules/services/web-apps/netbox.nix4
-rw-r--r--nixos/modules/services/web-apps/nextcloud.nix2
-rw-r--r--nixos/modules/services/web-apps/onlyoffice.nix2
-rw-r--r--nixos/modules/services/web-apps/outline.nix2
-rw-r--r--nixos/modules/services/web-apps/peering-manager.nix4
-rw-r--r--nixos/modules/services/web-apps/pixelfed.nix1
-rw-r--r--nixos/modules/services/web-apps/tt-rss.nix13
-rw-r--r--nixos/modules/services/web-servers/hydron.nix2
-rw-r--r--nixos/tests/dex-oidc.nix2
-rw-r--r--nixos/tests/ferretdb.nix2
-rw-r--r--nixos/tests/freshrss-pgsql.nix4
-rw-r--r--nixos/tests/grafana/basic.nix2
-rw-r--r--nixos/tests/hockeypuck.nix2
-rw-r--r--nixos/tests/home-assistant.nix12
-rw-r--r--nixos/tests/paperless.nix2
-rw-r--r--nixos/tests/pgadmin4.nix8
-rw-r--r--nixos/tests/pgbouncer.nix12
-rw-r--r--nixos/tests/powerdns-admin.nix4
-rw-r--r--nixos/tests/sftpgo.nix2
-rw-r--r--nixos/tests/tandoor-recipes.nix23
-rw-r--r--nixos/tests/vikunja.nix2
-rw-r--r--nixos/tests/wiki-js.nix5
47 files changed, 176 insertions, 153 deletions
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix
index af4db5c9611f..3d2205b63555 100644
--- a/nixos/modules/services/databases/postgresql.nix
+++ b/nixos/modules/services/databases/postgresql.nix
@@ -165,25 +165,13 @@ in
'';
};
- ensurePermissions = mkOption {
- type = types.attrsOf types.str;
- default = {};
- description = lib.mdDoc ''
- Permissions to ensure for the user, specified as an attribute set.
- The attribute names specify the database and tables to grant the permissions for.
- The attribute values specify the permissions to grant. You may specify one or
- multiple comma-separated SQL privileges here.
-
- For more information on how to specify the target
- and on which privileges exist, see the
- [GRANT syntax](https://www.postgresql.org/docs/current/sql-grant.html).
- The attributes are used as `GRANT ''${attrValue} ON ''${attrName}`.
- '';
- example = literalExpression ''
- {
- "DATABASE \"nextcloud\"" = "ALL PRIVILEGES";
- "ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
- }
+ ensureDBOwnership = mkOption {
+ type = types.bool;
+ default = false;
+ description = mdDoc ''
+ Grants the user ownership to a database with the same name.
+ This database must be defined manually in
+ [](#opt-services.postgresql.ensureDatabases).
'';
};
@@ -338,26 +326,21 @@ in
});
default = [];
description = lib.mdDoc ''
- Ensures that the specified users exist and have at least the ensured permissions.
+ Ensures that the specified users exist.
The PostgreSQL users will be identified using peer authentication. This authenticates the Unix user with the
same name only, and that without the need for a password.
- This option will never delete existing users or remove permissions, especially not when the value of this
- option is changed. This means that users created and permissions assigned once through this option or
- otherwise have to be removed manually.
+ This option will never delete existing users or remove DB ownership of databases
+ once granted with `ensureDBOwnership = true;`. This means that this must be
+ cleaned up manually when changing after changing the config in here.
'';
example = literalExpression ''
[
{
name = "nextcloud";
- ensurePermissions = {
- "DATABASE nextcloud" = "ALL PRIVILEGES";
- };
}
{
name = "superuser";
- ensurePermissions = {
- "ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
- };
+ ensureDBOwnership = true;
}
]
'';
@@ -445,6 +428,19 @@ 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`.
+ '';
+ }
+ ];
+
services.postgresql.settings =
{
hba_file = "${pkgs.writeText "pg_hba.conf" cfg.authentication}";
@@ -557,11 +553,9 @@ in
concatMapStrings
(user:
let
- userPermissions = concatStringsSep "\n"
- (mapAttrsToList
- (database: permission: ''$PSQL -tAc 'GRANT ${permission} ON ${database} TO "${user.name}"' '')
- user.ensurePermissions
- );
+ dbOwnershipStmt = optionalString
+ user.ensureDBOwnership
+ ''$PSQL -tAc 'ALTER DATABASE "${user.name}" OWNER TO "${user.name}";' '';
filteredClauses = filterAttrs (name: value: value != null) user.ensureClauses;
@@ -570,8 +564,9 @@ in
userClauses = ''$PSQL -tAc 'ALTER ROLE "${user.name}" ${concatStringsSep " " clauseSqlStatements}' '';
in ''
$PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname='${user.name}'" | grep -q 1 || $PSQL -tAc 'CREATE USER "${user.name}"'
- ${userPermissions}
${userClauses}
+
+ ${dbOwnershipStmt}
''
)
cfg.ensureUsers
diff --git a/nixos/modules/services/development/zammad.nix b/nixos/modules/services/development/zammad.nix
index 7dd143eebf12..d24ed24ef395 100644
--- a/nixos/modules/services/development/zammad.nix
+++ b/nixos/modules/services/development/zammad.nix
@@ -204,7 +204,7 @@ in
assertions = [
{
- assertion = cfg.database.createLocally -> cfg.database.user == "zammad";
+ assertion = cfg.database.createLocally -> cfg.database.user == "zammad" && cfg.database.name == "zammad";
message = "services.zammad.database.user must be set to \"zammad\" if services.zammad.database.createLocally is set to true";
}
{
@@ -231,7 +231,7 @@ in
ensureUsers = [
{
name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/finance/odoo.nix b/nixos/modules/services/finance/odoo.nix
index eec7c4e30cc4..b8574ed09af9 100644
--- a/nixos/modules/services/finance/odoo.nix
+++ b/nixos/modules/services/finance/odoo.nix
@@ -121,7 +121,7 @@ in
ensureDatabases = [ "odoo" ];
ensureUsers = [{
name = "odoo";
- ensurePermissions = { "DATABASE odoo" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}];
};
});
diff --git a/nixos/modules/services/mail/listmonk.nix b/nixos/modules/services/mail/listmonk.nix
index 11b2a5186229..cea1bc956081 100644
--- a/nixos/modules/services/mail/listmonk.nix
+++ b/nixos/modules/services/mail/listmonk.nix
@@ -168,7 +168,7 @@ in {
ensureUsers = [{
name = "listmonk";
- ensurePermissions = { "DATABASE listmonk" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}];
ensureDatabases = [ "listmonk" ];
diff --git a/nixos/modules/services/mail/roundcube.nix b/nixos/modules/services/mail/roundcube.nix
index 22a4e3c451ab..4e29f567ed92 100644
--- a/nixos/modules/services/mail/roundcube.nix
+++ b/nixos/modules/services/mail/roundcube.nix
@@ -179,14 +179,22 @@ in
};
};
+ assertions = [
+ {
+ assertion = localDB -> cfg.database.username == cfg.database.dbname;
+ message = ''
+ When setting up a DB and its owner user, the owner and the DB name must be
+ equal!
+ '';
+ }
+ ];
+
services.postgresql = mkIf localDB {
enable = true;
ensureDatabases = [ cfg.database.dbname ];
ensureUsers = [ {
name = cfg.database.username;
- ensurePermissions = {
- "DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";
- };
+ ensureDBOwnership = true;
} ];
};
diff --git a/nixos/modules/services/mail/sympa.nix b/nixos/modules/services/mail/sympa.nix
index 7a5047b2bea5..04ae46f66eea 100644
--- a/nixos/modules/services/mail/sympa.nix
+++ b/nixos/modules/services/mail/sympa.nix
@@ -218,7 +218,7 @@ in
default = null;
example = "/run/keys/sympa-dbpassword";
description = lib.mdDoc ''
- A file containing the password for {option}`services.sympa.database.user`.
+ A file containing the password for {option}`services.sympa.database.name`.
'';
};
@@ -342,6 +342,7 @@ in
db_type = cfg.database.type;
db_name = cfg.database.name;
+ db_user = cfg.database.name;
}
// (optionalAttrs (cfg.database.host != null) {
db_host = cfg.database.host;
@@ -355,9 +356,6 @@ in
// (optionalAttrs (cfg.database.port != null) {
db_port = cfg.database.port;
})
- // (optionalAttrs (cfg.database.user != null) {
- db_user = cfg.database.user;
- })
// (optionalAttrs (cfg.mta.type == "postfix") {
sendmail_aliases = "${dataDir}/sympa_transport";
aliases_program = "${pkgs.postfix}/bin/postmap";
@@ -393,7 +391,7 @@ in
users.groups.${group} = {};
assertions = [
- { assertion = cfg.database.createLocally -> cfg.database.user == user;
+ { assertion = cfg.database.createLocally -> cfg.database.user == user && cfg.database.name == cfg.database.user;
message = "services.sympa.database.user must be set to ${user} if services.sympa.database.createLocally is set to true";
}
{ assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
@@ -579,7 +577,7 @@ in
ensureDatabases = [ cfg.database.name ];
ensureUsers = [
{ name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/matrix/matrix-sliding-sync.nix b/nixos/modules/services/matrix/matrix-sliding-sync.nix
index 9807cde40919..84bb38f35aeb 100644
--- a/nixos/modules/services/matrix/matrix-sliding-sync.nix
+++ b/nixos/modules/services/matrix/matrix-sliding-sync.nix
@@ -74,9 +74,9 @@ in
services.postgresql = lib.optionalAttrs cfg.createDatabase {
enable = true;
ensureDatabases = [ "matrix-sliding-sync" ];
- ensureUsers = [ rec {
+ ensureUsers = [ {
name = "matrix-sliding-sync";
- ensurePermissions."DATABASE \"${name}\"" = "ALL PRIVILEGES";
+ ensureDBOwnership = true;
} ];
};
diff --git a/nixos/modules/services/matrix/mautrix-facebook.nix b/nixos/modules/services/matrix/mautrix-facebook.nix
index 671040500df8..d7cf024bb807 100644
--- a/nixos/modules/services/matrix/mautrix-facebook.nix
+++ b/nixos/modules/services/matrix/mautrix-facebook.nix
@@ -135,9 +135,7 @@ in {
ensureDatabases = ["mautrix-facebook"];
ensureUsers = [{
name = "mautrix-facebook";
- ensurePermissions = {
- "DATABASE \"mautrix-facebook\"" = "ALL PRIVILEGES";
- };
+ ensureDBOwnership = true;
}];
};
diff --git a/nixos/modules/services/misc/atuin.nix b/nixos/modules/services/misc/atuin.nix
index 8d2c1b5242ff..2d6ffc510ce5 100644
--- a/nixos/modules/services/misc/atuin.nix
+++ b/nixos/modules/services/misc/atuin.nix
@@ -73,9 +73,7 @@ in
enable = true;
ensureUsers = [{
name = "atuin";
- ensurePermissions = {
- "DATABASE atuin" = "ALL PRIVILEGES";
- };
+ ensureDBOwnership = true;
}];
ensureDatabases = [ "atuin" ];
};
diff --git a/nixos/modules/services/misc/forgejo.nix b/nixos/modules/services/misc/forgejo.nix
index 90b5f16f4189..6f459048f347 100644
--- a/nixos/modules/services/misc/forgejo.nix
+++ b/nixos/modules/services/misc/forgejo.nix
@@ -357,6 +357,14 @@ in
assertion = cfg.database.createDatabase -> useSqlite || cfg.database.user == cfg.user;
message = "services.forgejo.database.user must match services.forgejo.user if the database is to be automatically provisioned";
}
+ { assertion = cfg.database.createDatabase && usePostgresql -> cfg.database.user == cfg.database.name;
+ message = ''
+ When creating a database via NixOS, the db user and db name must be equal!
+ If you already have an existing DB+user and this assertion is new, you can safely set
+ `services.forgejo.createDatabase` to `false` because removal of `ensureUsers`
+ and `ensureDatabases` doesn't have any effect.
+ '';
+ }
];
services.forgejo.settings = {
@@ -423,7 +431,7 @@ in
ensureUsers = [
{
name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix
index 3f690f85d623..be528a298991 100644
--- a/nixos/modules/services/misc/gitea.nix
+++ b/nixos/modules/services/misc/gitea.nix
@@ -394,6 +394,14 @@ in
{ assertion = cfg.database.createDatabase -> useSqlite || cfg.database.user == cfg.user;
message = "services.gitea.database.user must match services.gitea.user if the database is to be automatically provisioned";
}
+ { assertion = cfg.database.createDatabase && usePostgresql -> cfg.database.user == cfg.database.name;
+ message = ''
+ When creating a database via NixOS, the db user and db name must be equal!
+ If you already have an existing DB+user and this assertion is new, you can safely set
+ `services.gitea.createDatabase` to `false` because removal of `ensureUsers`
+ and `ensureDatabases` doesn't have any effect.
+ '';
+ }
];
services.gitea.settings = {
@@ -461,7 +469,7 @@ in
ensureDatabases = [ cfg.database.name ];
ensureUsers = [
{ name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/misc/redmine.nix b/nixos/modules/services/misc/redmine.nix
index a296fd3816bb..20fa71507b6b 100644
--- a/nixos/modules/services/misc/redmine.nix
+++ b/nixos/modules/services/misc/redmine.nix
@@ -267,7 +267,7 @@ in
{ assertion = cfg.database.passwordFile != null || cfg.database.socket != null;
message = "one of services.redmine.database.socket or services.redmine.database.passwordFile must be set";
}
- { assertion = cfg.database.createLocally -> cfg.database.user == cfg.user;
+ { assertion = cfg.database.createLocally -> cfg.database.user == cfg.user && cfg.database.user == cfg.database.name;
message = "services.redmine.database.user must be set to ${cfg.user} if services.redmine.database.createLocally is set true";
}
{ assertion = cfg.database.createLocally -> cfg.database.socket != null;
@@ -315,7 +315,7 @@ in
ensureDatabases = [ cfg.database.name ];
ensureUsers = [
{ name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/misc/sourcehut/service.nix b/nixos/modules/services/misc/sourcehut/service.nix
index 18c2f5effc5a..d2cd599d3fec 100644
--- a/nixos/modules/services/misc/sourcehut/service.nix
+++ b/nixos/modules/services/misc/sourcehut/service.nix
@@ -242,6 +242,15 @@ in
} cfg.nginx.virtualHost ];
};
+ assertions = [
+ {
+ assertion = srvCfg.user == srvCfg.postgresql.database;
+ message = ''
+ When creating a database via NixOS, the db user and db name must be equal!
+ '';
+ }
+ ];
+
services.postgresql = mkIf cfg.postgresql.enable {
authentication = ''
local ${srvCfg.postgresql.database} ${srvCfg.user} trust
@@ -249,7 +258,7 @@ in
ensureDatabases = [ srvCfg.postgresql.database ];
ensureUsers = map (name: {
inherit name;
- ensurePermissions = { "DATABASE \"${srvCfg.postgresql.database}\"" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}) [srvCfg.user];
};
diff --git a/nixos/modules/services/monitoring/zabbix-proxy.nix b/nixos/modules/services/monitoring/zabbix-proxy.nix
index 85da416ba6c3..503e81b48a58 100644
--- a/nixos/modules/services/monitoring/zabbix-proxy.nix
+++ b/nixos/modules/services/monitoring/zabbix-proxy.nix
@@ -203,7 +203,7 @@ in
{ assertion = !config.services.zabbixServer.enable;
message = "Please choose one of services.zabbixServer or services.zabbixProxy.";
}
- { assertion = cfg.database.createLocally -> cfg.database.user == user;
+ { assertion = cfg.database.createLocally -> cfg.database.user == user && cfg.database.name == cfg.database.user;
message = "services.zabbixProxy.database.user must be set to ${user} if services.zabbixProxy.database.createLocally is set true";
}
{ assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
@@ -252,7 +252,7 @@ in
ensureDatabases = [ cfg.database.name ];
ensureUsers = [
{ name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/monitoring/zabbix-server.nix b/nixos/modules/services/monitoring/zabbix-server.nix
index 2b50280e3969..0607188d2131 100644
--- a/nixos/modules/services/monitoring/zabbix-server.nix
+++ b/nixos/modules/services/monitoring/zabbix-server.nix
@@ -191,7 +191,7 @@ in
config = mkIf cfg.enable {
assertions = [
- { assertion = cfg.database.createLocally -> cfg.database.user == user;
+ { assertion = cfg.database.createLocally -> cfg.database.user == user && cfg.database.user == cfg.database.name;
message = "services.zabbixServer.database.user must be set to ${user} if services.zabbixServer.database.createLocally is set true";
}
{ assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
@@ -240,7 +240,7 @@ in
ensureDatabases = [ cfg.database.name ];
ensureUsers = [
{ name = cfg.database.user;
- ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/security/hockeypuck.nix b/nixos/modules/services/security/hockeypuck.nix
index 127134bc5dba..56c13d791920 100644
--- a/nixos/modules/services/security/hockeypuck.nix
+++ b/nixos/modules/services/security/hockeypuck.nix
@@ -55,7 +55,7 @@ in {
ensureDatabases = [ "hockeypuck" ];
ensureUsers = [{
name = "hockeypuck";
- ensurePermissions."DATABASE hockeypuck" = "ALL PRIVILEGES";
+ ensureDBOwnership = true;
}];
};
```
diff --git a/nixos/modules/services/web-apps/coder.nix b/nixos/modules/services/web-apps/coder.nix
index 469a29bc3aa8..f65211308c40 100644
--- a/nixos/modules/services/web-apps/coder.nix
+++ b/nixos/modules/services/web-apps/coder.nix
@@ -149,8 +149,8 @@ in {
config = mkIf cfg.enable {
assertions = [
- { assertion = cfg.database.createLocally -> cfg.database.username == name;
- message = "services.coder.database.username must be set to ${user} if services.coder.database.createLocally is set true";
+ { assertion = cfg.database.createLocally -> cfg.database.username == name && cfg.database.database == cfg.database.username;
+ message = "services.coder.database.username must be set to ${name} if services.coder.database.createLocally is set true";
}
];
@@ -193,10 +193,8 @@ in {
cfg.database.database
];
ensureUsers = [{
- name = cfg.database.username;
- ensurePermissions = {
- "DATABASE \"${cfg.database.database}\"" = "ALL PRIVILEGES";
- };
+ name = cfg.user;
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/web-apps/gotosocial.nix b/nixos/modules/services/web-apps/gotosocial.nix
index f7ae018d5b7c..9c21719a5759 100644
--- a/nixos/modules/services/web-apps/gotosocial.nix
+++ b/nixos/modules/services/web-apps/gotosocial.nix
@@ -128,9 +128,7 @@ in
ensureUsers = [
{
name = "gotosocial";
- ensurePermissions = {
- "DATABASE gotosocial" = "ALL PRIVILEGES";
- };
+ ensureDBOwnership = true;
}
];
};
diff --git a/nixos/modules/services/web-apps/invidious.nix b/nixos/modules/services/web-apps/invidious.nix
index 5603ef7392e8..fc9c1ec06f65 100644
--- a/nixos/modules/services/web-apps/invidious.nix
+++ b/nixos/modules/services/web-apps/invidious.nix
@@ -112,12 +112,6 @@ let
services.postgresql = {
enable = true;
ensureDatabases = lib.singleton cfg.settings.db.dbname;
- ensureUsers = lib.singleton {
- name = cfg.settings.db.user;
- ensurePermissions = {
- "DATABASE ${cfg.settings.db.dbname}" = "ALL PRIVILEGES";
- };
- };
# This is only needed because the unix user invidious isn't the same as
# the database user. This tells postgres to map one to the other.
identMap = ''
diff --git a/nixos/modules/services/web-apps/lemmy.nix b/nixos/modules/services/web-apps/lemmy.nix
index 20d9dcb7c266..32389f7a59dd 100644
--- a/nixos/modules/services/web-apps/lemmy.nix
+++ b/nixos/modules/services/web-apps/lemmy.nix
@@ -146,7 +146,7 @@ in
ensureDatabases = [ cfg.settings.database.database ];
ensureUsers = [{
name = cfg.settings.database.user;
- ensurePermissions."DATABASE ${cfg.settings.database.database}" = "ALL PRIVILEGES";
+ ensureDBOwnership = true;
}];
};
diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix
index 2aab97438b7d..5feca2525ea1 100644
--- a/nixos/modules/services/web-apps/mastodon.nix
+++ b/nixos/modules/services/web-apps/mastodon.nix
@@ -557,7 +557,7 @@ in {
config = lib.mkIf cfg.enable (lib.mkMerge [{
assertions = [
{
- assertion = databaseActuallyCreateLocally -> (cfg.user == cfg.database.user);
+ assertion = databaseActuallyCreateLocally -> (cfg.user == cfg.database.user && cfg.database.