Add synapse user and database

This commit is contained in:
Ivan R. 2023-08-19 09:39:02 +05:00
parent 8037006825
commit 3b93b3006b
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
2 changed files with 21 additions and 6 deletions

View file

@ -3,27 +3,35 @@
config.services.postgresql = { config.services.postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_15; package = pkgs.postgresql_15;
ensureDatabases = [ "mastodon" "synapse" "nextcloud" ]; ensureDatabases = [ "mastodon" "matrix-synapse" "nextcloud" ];
ensureUsers = [ ensureUsers = [
{ {
name = "mastodon"; name = "mastodon";
ensurePermissions = { ensurePermissions = {
"DATABASE mastodon" = "ALL PRIVILEGES"; "DATABASE mastodon" = "ALL PRIVILEGES";
}; };
ensureClauses = { ensureClauses.login = true;
login = true;
};
} }
{ {
name = "nextcloud"; name = "nextcloud";
ensurePermissions = { ensurePermissions = {
"DATABASE nextcloud" = "ALL PRIVILEGES"; "DATABASE nextcloud" = "ALL PRIVILEGES";
}; };
ensureClauses = { ensureClauses.login = true;
login = true; }
{
name = "matrix-synapse";
ensurePermissions = {
"DATABASE \"matrix-synapse\"" = "ALL PRIVILEGES";
}; };
ensureClauses.login = true;
} }
]; ];
initialScript = pkgs.writeText "pg-init.sql" ''
ALTER DATABASE nextcloud OWNER TO nextcloud;
ALTER DATABASE mastodon OWNER TO mastodon;
ALTER DATABASE "matrix-synapse" OWNER TO "matrix-synapse";
'';
identMap = '' identMap = ''
# ArbitraryMapName systemUser DBUser # ArbitraryMapName systemUser DBUser
superuser_map root postgres superuser_map root postgres

View file

@ -20,6 +20,10 @@
isSystemUser = true; isSystemUser = true;
group = "photoprism"; group = "photoprism";
}; };
matrix-synapse = {
isSystemUser = true;
group = "matrix-synapse";
};
}; };
users.groups = { users.groups = {
@ -32,5 +36,8 @@
photoprism = { photoprism = {
members = [ "photoprism" config.services.nginx.user ]; members = [ "photoprism" config.services.nginx.user ];
}; };
matrix-synapse = {
members = [ "matrix-synapse" config.services.nginx.user ];
};
}; };
} }