Add postgresql module

This commit is contained in:
Jordan Holt 2024-07-08 22:13:36 +01:00
parent 162e7bc114
commit 31c747812e
Signed by: jordan
GPG Key ID: B8CFFF61F1CCF520
4 changed files with 48 additions and 5 deletions

View File

@ -43,7 +43,8 @@
services.openssh.settings.PermitRootLogin = lib.mkForce "prohibit-password";
modules = {
modules = rec {
databases.postgresql.enable = true;
services = {
borgmatic = {
enable = true;
@ -61,7 +62,10 @@
};
gitea.enable = true;
headscale.enable = true;
matrix-synapse.enable = true;
matrix-synapse = {
enable = true;
usePostgresql = databases.postgresql.enable;
};
nginx.enable = true;
photoprism.enable = true;
};

View File

@ -0,0 +1,38 @@
{
config,
lib,
...
}:
let
cfg = config.modules.databases.postgresql;
in {
options.modules.databases.postgresql = {
enable = lib.mkOption {
default = false;
example = true;
};
};
config = lib.mkIf cfg.enable {
services.postgresql = {
enable = true;
initdbArgs = [
"--allow-group-access"
];
settings = {
log_connections = true;
log_disconnections = true;
log_destination = lib.mkForce "syslog";
};
};
services.borgmatic.settings = {
postgresql_databases = [
{
name = "all";
}
];
};
};
}

View File

@ -2,6 +2,7 @@
imports = [
./options.nix
./podman.nix
./databases/postgresql.nix
./desktop/gnome.nix
./desktop/forensics.nix
./desktop/hyprland.nix

View File

@ -22,7 +22,7 @@ in {
default = "vimium.com";
example = "vimium.com";
};
usePostgres = lib.mkOption {
usePostgresql = lib.mkOption {
default = false;
example = true;
};
@ -129,7 +129,7 @@ in {
services.matrix-synapse = {
enable = true;
settings = {
database.name = (if cfg.usePostgres then "psycopg2" else "sqlite3");
database.name = (if cfg.usePostgresql then "psycopg2" else "sqlite3");
enable_metrics = false;
enable_registration = false;
max_upload_size = "100M";
@ -138,7 +138,7 @@ in {
};
};
services.postgresql = lib.mkIf cfg.usePostgres {
services.postgresql = lib.mkIf cfg.usePostgresql {
ensureUsers = [
{
name = "matrix-synapse";