gerd.postgresql: initial add
This commit is contained in:
parent
b9163999bb
commit
84a3027d0c
3 changed files with 55 additions and 0 deletions
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
./../shared/applications/server/acme.nix
|
./../shared/applications/server/acme.nix
|
||||||
./../shared/applications/server/nginx.nix
|
./../shared/applications/server/nginx.nix
|
||||||
|
./../shared/applications/server/postgresql.nix
|
||||||
|
./../shared/applications/state/postgresql.nix
|
||||||
./../shared/applications/state/ssh.nix
|
./../shared/applications/state/ssh.nix
|
||||||
|
|
||||||
./gerd/services/fricloud-website.nix
|
./gerd/services/fricloud-website.nix
|
||||||
|
@ -31,6 +33,8 @@
|
||||||
"safe/svcs/hedgedoc" = { mountpoint = "/srv/hedgedoc"; extra.options.quota = "5G"; };
|
"safe/svcs/hedgedoc" = { mountpoint = "/srv/hedgedoc"; extra.options.quota = "5G"; };
|
||||||
"safe/svcs/nextcloud" = { mountpoint = "/srv/nextcloud"; extra.options.quota = "5G"; };
|
"safe/svcs/nextcloud" = { mountpoint = "/srv/nextcloud"; extra.options.quota = "5G"; };
|
||||||
"safe/svcs/stalwart" = { mountpoint = "/srv/stalwart"; extra.options.quota = "5G"; };
|
"safe/svcs/stalwart" = { mountpoint = "/srv/stalwart"; extra.options.quota = "5G"; };
|
||||||
|
"safe/svcs/postgresql" = { mountpoint = "/srv/postgresql"; extra.options.quota = "5G"; };
|
||||||
|
"backup/postgresql" = { mountpoint = "/media/backup/postgresqlbackup"; extra.options.quota = "5G"; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
31
shared/applications/server/postgresql.nix
Normal file
31
shared/applications/server/postgresql.nix
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.postgresql = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# backup postgresql databases (everything in ensuredatabases)
|
||||||
|
services.postgresqlBackup = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
compression = "zstd";
|
||||||
|
|
||||||
|
# default to backup all databadatabases
|
||||||
|
databases = config.services.postgresql.ensureDatabases;
|
||||||
|
};
|
||||||
|
|
||||||
|
# default the locale to C. I have NO CLUE why you would
|
||||||
|
# like to use any other locale, than the default C.
|
||||||
|
# However, matrix synapse complains A LOT if it isn't C,
|
||||||
|
# so we just default to it! No worries!
|
||||||
|
# Matrix Synapse Locale Note
|
||||||
|
# - https://github.com/element-hq/synapse/blob/develop/docs/postgres.md#fixing-incorrect-collate-or-ctype
|
||||||
|
# NOTE from postgresql here https://www.postgresql.org/docs/current/locale.html
|
||||||
|
# Using C.UTF-8, because setting `LC_CTYPE=C` will default encoding to SQL_ASCII.
|
||||||
|
# https://pganalyze.com/blog/5mins-postgres-17-builtin-c-utf8-locale
|
||||||
|
systemd.services.postgresql.environment = {
|
||||||
|
LC_CTYPE = "C.UTF-8";
|
||||||
|
LC_COLLATE = "C";
|
||||||
|
};
|
||||||
|
}
|
20
shared/applications/state/postgresql.nix
Normal file
20
shared/applications/state/postgresql.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
stateDir= config.mine.zfsMounts."rpool/safe/svcs/postgresql";
|
||||||
|
backupDir = config.mine.zfsMounts."rpool/backup/postgresql";
|
||||||
|
|
||||||
|
postgresql_user = config.systemd.services.postgresql.serviceConfig.User;
|
||||||
|
postgresql_group = config.systemd.services.postgresql.serviceConfig.Group;
|
||||||
|
in {
|
||||||
|
services.postgresql.dataDir = stateDir;
|
||||||
|
|
||||||
|
# backup postgresql databases (everything in ensuredatabases)
|
||||||
|
services.postgresqlBackup.location = backupDir;
|
||||||
|
|
||||||
|
# ensure correct permissions for postgresql and postgresql backup
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"Z ${stateDir} 0770 ${postgresql_user} ${postgresql_group} -"
|
||||||
|
"Z ${backupDir} 0770 ${postgresql_user} ${postgresql_group} -"
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue