summary refs log tree commit diff
path: root/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/postgres.nix
blob: b3c8cadbec3ceec05a590fff030532f8f0361650 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ config, pkgs, lib, ... }:

{
  #systemd.tmpfiles.rules = [  "d /data/pg 0750 postgres postgres" ];

  services.postgresql = {
    enable = true;
    package = pkgs.postgresql_15;
    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 all all 0.0.0.0/0 md5
    '';
    initialScript = pkgs.writeText "backend-initScript" ''
      CREATE ROLE spacebar WITH LOGIN PASSWORD 'spacebar' CREATEDB;
      CREATE DATABASE spacebar WITH OWNER spacebar ENCODING 'UTF8';
      GRANT ALL PRIVILEGES ON DATABASE spacebar TO spacebar;
    '';
    #dataDir = "/data/pg";
    settings = {
      "max_connections" = "100";
      "shared_buffers" = "128MB";
      "max_wal_size" = "1GB";
      "min_wal_size" = "80MB";
    };
  };
}