2023-11-18 14:46:04 +01:00
|
|
|
{
|
|
|
|
makeSystem,
|
|
|
|
nixpkgs,
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(nixpkgs.lib)
|
|
|
|
singleton
|
|
|
|
;
|
2023-06-13 23:07:31 +02:00
|
|
|
in
|
2023-11-18 14:46:04 +01:00
|
|
|
makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "nixng-hydra-postgresql";
|
|
|
|
inherit nixpkgs;
|
|
|
|
config = {
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: {
|
2023-06-13 23:07:31 +02:00
|
|
|
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-10-23 13:49:59 +02:00
|
|
|
config = {
|
2023-11-18 14:46:04 +01:00
|
|
|
# DB Version: 12
|
|
|
|
# OS Type: linux
|
|
|
|
# DB Type: mixed
|
|
|
|
# Total Memory (RAM): 1 GB
|
|
|
|
# CPUs num: 12
|
|
|
|
# Connections num: 512
|
|
|
|
# Data Storage: hdd
|
|
|
|
|
|
|
|
max_connections = 512;
|
|
|
|
shared_buffers = "256 MB";
|
|
|
|
effective_cache_size = "768 MB";
|
|
|
|
maintenance_work_mem = "64 MB";
|
|
|
|
checkpoint_completion_target = 0.9;
|
|
|
|
wal_buffers = "7864 kB";
|
|
|
|
default_statistics_target = 100;
|
|
|
|
random_page_cost = 4;
|
|
|
|
effective_io_concurrency = 2;
|
|
|
|
work_mem = "64 kB";
|
|
|
|
huge_pages = "off";
|
|
|
|
min_wal_size = "1 GB";
|
|
|
|
max_wal_size = "4 GB";
|
|
|
|
max_worker_processes = 12;
|
|
|
|
max_parallel_workers_per_gather = 4;
|
|
|
|
max_parallel_workers = 12;
|
|
|
|
max_parallel_maintenance_workers = 4;
|
2023-10-23 13:49:59 +02:00
|
|
|
};
|
|
|
|
|
2023-11-18 14:46:04 +01:00
|
|
|
ensureDatabases = ["hydra"];
|
2023-06-13 23:07:31 +02:00
|
|
|
ensureExtensions = {
|
2023-11-18 14:46:04 +01:00
|
|
|
"pg_trgm" = ["hydra"];
|
2023-06-13 23:07:31 +02:00
|
|
|
};
|
|
|
|
ensureUsers = singleton {
|
|
|
|
name = "hydra";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE \"hydra\"" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-11-18 14:46:04 +01:00
|
|
|
}
|