summary refs log tree commit diff
path: root/host/Rory-postgres/configuration.nix
blob: 608165235b438750f11863b0b9ec5ced026c88bc (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
31
32
33
34
35
36
37
38
39
40
41
42
43
{ config, pkgs, lib, ... }:

{
  imports =
    [
      ../../modules/base-server.nix
    ];

  networking = {
    hostName = "Rory-postgres";
    interfaces.ens18.ipv4.addresses = [ { 
      address = "192.168.1.3";
      prefixLength = 24;
    } ];
  };

  # environment.systemPackages = with pkgs; [
  #   postgresql
  # ];

  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 discordbots discordbots 192.168.1.1/24 trust
      host all all 0.0.0.0 md5
    '';
    # initialScript = pkgs.writeText "backend-initScript" ''
    #   CREATE ROLE nixcloud WITH LOGIN PASSWORD 'nixcloud' CREATEDB;
    #   CREATE DATABASE nixcloud;
    #   GRANT ALL PRIVILEGES ON DATABASE nixcloud TO nixcloud;
    # '';
    dataDir = "/data/pg";
  };

  system.stateVersion = "22.11"; # DO NOT EDIT!
}