2023-06-13 23:05:35 +02:00
|
|
|
{ makeSystem
|
|
|
|
, nixpkgs
|
|
|
|
}:
|
|
|
|
makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "nixng-synapse-postgresql";
|
|
|
|
inherit nixpkgs;
|
|
|
|
config =
|
|
|
|
{ pkgs, config, ... }:
|
|
|
|
{
|
|
|
|
config = {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = {};
|
|
|
|
};
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.postgresql_12;
|
|
|
|
|
|
|
|
initialScript = "/secrets/init.sql";
|
|
|
|
enableTCPIP = true;
|
|
|
|
|
|
|
|
authentication = "host all all all md5";
|
|
|
|
|
2023-06-29 19:11:26 +02:00
|
|
|
config = {
|
2023-07-09 23:42:46 +02:00
|
|
|
max_connections = 70;
|
2023-06-29 19:11:26 +02:00
|
|
|
shared_buffers = "384MB";
|
|
|
|
effective_cache_size = "1152MB";
|
|
|
|
maintenance_work_mem = "96MB";
|
|
|
|
checkpoint_completion_target = "0.9";
|
|
|
|
wal_buffers = "11796kB";
|
|
|
|
default_statistics_target = 100;
|
|
|
|
random_page_cost = 4;
|
|
|
|
effective_io_concurrency = 2;
|
|
|
|
work_mem = "1966kB";
|
|
|
|
min_wal_size = "1GB";
|
|
|
|
max_wal_size = "4GB";
|
2023-07-09 23:42:46 +02:00
|
|
|
max_worker_processes = 24;
|
2023-06-29 19:11:26 +02:00
|
|
|
max_parallel_workers_per_gather = 4;
|
2023-07-09 23:42:46 +02:00
|
|
|
max_parallel_workers = 24;
|
2023-06-29 19:11:26 +02:00
|
|
|
max_parallel_maintenance_workers = 4;
|
|
|
|
};
|
|
|
|
|
2023-06-13 23:05:35 +02:00
|
|
|
ensureDatabases = {
|
|
|
|
"synapse" = { ENCODING = "UTF8"; TEMPLATE = "template0"; };
|
|
|
|
"mautrix-facebook" = { ENCODING = "UTF8"; TEMPLATE = "template0"; };
|
|
|
|
"mautrix-signal" = { ENCODING = "UTF8"; TEMPLATE = "template0"; };
|
|
|
|
"mautrix-whatsapp" = { ENCODING = "UTF8"; TEMPLATE = "template0"; };
|
|
|
|
"mautrix-discord" = { ENCODING = "UTF8"; TEMPLATE = "template0"; };
|
|
|
|
};
|
|
|
|
ensureExtensions = {};
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "synapse";
|
|
|
|
ensurePermissions."DATABASE \"synapse\"" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "mautrix-facebook";
|
|
|
|
ensurePermissions."DATABASE \"mautrix-facebook\"" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "mautrix-signal";
|
|
|
|
ensurePermissions."DATABASE \"mautrix-signal\"" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "mautrix-whatsapp";
|
|
|
|
ensurePermissions."DATABASE \"mautrix-whatsapp\"" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "mautrix-discord";
|
|
|
|
ensurePermissions."DATABASE \"mautrix-discord\"" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|