summary refs log tree commit diff
path: root/host/Spacebar-nginx/postgres.nix
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-25 19:12:45 +0200
committerRory& <root@rory.gay>2024-06-05 17:25:16 +0200
commitc47e2f0ab033cbb4ce54cadb6c024c20ad7b5145 (patch)
treecafe69cc37dbac1a2224ef1a01319cdec8f89910 /host/Spacebar-nginx/postgres.nix
parentMove boot target (diff)
downloadSpacebar-Open-Infrastructure-c47e2f0ab033cbb4ce54cadb6c024c20ad7b5145.tar.xz
Switch to nginx mainline
Diffstat (limited to 'host/Spacebar-nginx/postgres.nix')
-rw-r--r--host/Spacebar-nginx/postgres.nix31
1 files changed, 31 insertions, 0 deletions
diff --git a/host/Spacebar-nginx/postgres.nix b/host/Spacebar-nginx/postgres.nix
new file mode 100644
index 0000000..6d0acd9
--- /dev/null
+++ b/host/Spacebar-nginx/postgres.nix
@@ -0,0 +1,31 @@
+{ config, pkgs, lib, ... }:
+
+{
+  systemd.tmpfiles.rules = [  "d /data/pg 0750 postgres postgres" ];
+
+  services.postgresql = {
+    enable = true;
+    package = pkgs.postgresql_14;
+    enableTCPIP = true;
+    authentication = pkgs.lib.mkOverride 10 ''
+      # TYPE, DATABASE, USER, ADDRESS, METHOD
+      local all all trust
+      host all all 127.0.0.1/32 trust
+      host all all ::1/128 trust
+      host matrix-synapse-spacebar-chat matrix-synapse-spacebar-chat 192.168.1.5/32 trust
+      host all all 0.0.0.0/0 md5
+    '';
+    initialScript = pkgs.writeText "backend-initScript" ''
+      CREATE ROLE matrix-synapse-spacebar-chat WITH LOGIN PASSWORD '${pkgs.postgresql_14}' CREATEDB;
+      CREATE DATABASE matrix-synapse-spacebar-chat;
+      GRANT ALL PRIVILEGES ON DATABASE matrix-synapse-spacebar-chat TO matrix-synapse-spacebar-chat;
+    '';
+    dataDir = "/data/pg";
+    settings = {
+      "max_connections" = "100";
+      "shared_buffers" = "128MB";
+      "max_wal_size" = "1GB";
+      "min_wal_size" = "80MB";
+    };
+  };
+}
\ No newline at end of file