summaryrefslogtreecommitdiff
path: root/hosts/surtr/postgresql.nix
blob: e622f4e9c1ef3eb3fe4fa6a46af94c9f83b7dd4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{ pkgs, ... }:
{
  config = {
    services.postgresql = {
      enable = true;
      package = pkgs.postgresql_14;
      initialScript = pkgs.writeText "schema.sql" ''
        CREATE DATABASE "matrix-synapse" WITH TEMPLATE "template0" ENCODING "UTF8" LOCALE "C";
        CREATE USER "matrix-synapse";
        GRANT ALL PRIVILEGES ON DATABASE "matrix-synapse" TO "matrix-synapse";
        GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "matrix-synapse";

        CREATE DATABASE "mxisd" WITH TEMPLATE "template0" ENCODING "UTF8" LOCALE "C";
        CREATE USER "mxisd";
        GRANT ALL PRIVILEGES ON DATABASE "mxisd" TO "mxisd";
        GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "mxisd";
      '';
    };
  };
}