]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/databases/default.nix
Add mysql replication
[perso/Immae/Config/Nix.git] / modules / private / databases / default.nix
CommitLineData
8183b8bb 1{ lib, config, myconfig, nodes, ... }:
182ae57f
IB
2let
3 cfg = config.myServices.databases;
4in
5{
6 options.myServices = {
7 databases.enable = lib.mkEnableOption "my databases service";
8 databasesCerts = lib.mkOption {
9 description = "Default databases configurations for certificates as accepted by acme";
10 };
11 };
4aac110f
IB
12
13 config.nixpkgs.overlays = lib.mkIf cfg.enable [ (self: super: {
14 postgresql = self.postgresql_11_custom;
15 }) ];
16
182ae57f 17 config.myServices.databases = lib.mkIf cfg.enable {
4aac110f
IB
18 mariadb = {
19 enable = true;
20 ldapConfig = {
21 inherit (myconfig.env.ldap) host base;
22 inherit (myconfig.env.databases.mysql.pam) dn filter password;
23 };
9f6a7862
IB
24 replicationLdapConfig = {
25 inherit (myconfig.env.ldap) host base;
26 inherit (myconfig.env.ldap.eldiron) dn password;
27 };
4aac110f
IB
28 credentials.root = myconfig.env.databases.mysql.systemUsers.root;
29 };
30
31 openldap = {
32 accessFile = "${myconfig.privateFiles}/ldap.conf";
33 baseDn = myconfig.env.ldap.base;
34 rootDn = myconfig.env.ldap.root_dn;
35 rootPw = myconfig.env.ldap.root_pw;
36 enable = true;
37 };
38
39 postgresql = {
40 ldapConfig = {
41 inherit (myconfig.env.ldap) host base;
42 inherit (myconfig.env.databases.postgresql.pam) dn filter password;
43 };
44 replicationLdapConfig = {
ec9b6564
IB
45 inherit (myconfig.env.ldap) host base;
46 inherit (myconfig.env.ldap.eldiron) dn password;
4aac110f
IB
47 };
48 authorizedHosts = {
49 immaeEu = [{
50 ip4 = [
51 myconfig.env.servers.immaeEu.ips.main.ip4
52 myconfig.env.servers.immaeEu.ips.alt.ip4
53 ];
54 }];
55 };
56 replicationHosts = {
57 backup-1 = {
58 ip4 = [myconfig.env.servers.backup-1.ips.main.ip4];
59 ip6 = myconfig.env.servers.backup-1.ips.main.ip6;
60 };
8183b8bb
IB
61 backup-2 = {
62 ip4 = [myconfig.env.servers.backup-2.ips.main.ip4];
63 ip6 = myconfig.env.servers.backup-2.ips.main.ip6;
64 };
4aac110f
IB
65 };
66 enable = true;
67 };
68
182ae57f
IB
69 redis.enable = true;
70 };
71}