aboutsummaryrefslogtreecommitdiff
path: root/modules/private/databases/default.nix
blob: 73714107ff519ee70d82e3752f033e63429fb0a4 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ lib, config, myconfig, nodes, ... }:
let
  cfg = config.myServices.databases;
in
{
  options.myServices = {
    databases.enable = lib.mkEnableOption "my databases service";
    databasesCerts = lib.mkOption {
      description = "Default databases configurations for certificates as accepted by acme";
    };
  };

  config.nixpkgs.overlays = lib.mkIf cfg.enable [ (self: super: {
    postgresql = self.postgresql_11_custom;
  }) ];

  config.myServices.databases = lib.mkIf cfg.enable {
    mariadb = {
      enable = true;
      ldapConfig = {
        inherit (myconfig.env.ldap) host base;
        inherit (myconfig.env.databases.mysql.pam) dn filter password;
      };
      replicationLdapConfig = {
        inherit (myconfig.env.ldap) host base;
        inherit (myconfig.env.ldap.eldiron) dn password;
      };
      credentials.root = myconfig.env.databases.mysql.systemUsers.root;
    };

    openldap = {
      accessFile = "${myconfig.privateFiles}/ldap.conf";
      baseDn = myconfig.env.ldap.base;
      rootDn = myconfig.env.ldap.root_dn;
      rootPw = myconfig.env.ldap.root_pw;
      enable = true;
    };

    postgresql = {
      ldapConfig = {
        inherit (myconfig.env.ldap) host base;
        inherit (myconfig.env.databases.postgresql.pam) dn filter password;
      };
      replicationLdapConfig = {
        inherit (myconfig.env.ldap) host base;
        inherit (myconfig.env.ldap.eldiron) dn password;
      };
      authorizedHosts = {
        immaeEu = [{
          ip4 = [
            myconfig.env.servers.immaeEu.ips.main.ip4
            myconfig.env.servers.immaeEu.ips.alt.ip4
          ];
        }];
      };
      replicationHosts = {
        backup-1 = {
          ip4 = [myconfig.env.servers.backup-1.ips.main.ip4];
          ip6 = myconfig.env.servers.backup-1.ips.main.ip6;
        };
        backup-2 = {
          ip4 = [myconfig.env.servers.backup-2.ips.main.ip4];
          ip6 = myconfig.env.servers.backup-2.ips.main.ip6;
        };
      };
      enable = true;
    };

    redis.enable = true;
  };
}