]>
Commit | Line | Data |
---|---|---|
1 | { privateFiles }: | |
2 | { config, pkgs, resources, ... }: | |
3 | { | |
4 | boot.kernelPackages = pkgs.linuxPackages_latest; | |
5 | myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; | |
6 | hostEnv.FQDN = "backup-2.v.immae.eu"; | |
7 | ||
8 | imports = builtins.attrValues (import ../..); | |
9 | ||
10 | deployment = { | |
11 | targetEnv = "hetznerCloud"; | |
12 | hetznerCloud = { | |
13 | authToken = config.myEnv.hetznerCloud.authToken; | |
14 | datacenter = "hel1-dc2"; | |
15 | location ="hel1"; | |
16 | serverType = "cx11"; | |
17 | }; | |
18 | }; | |
19 | ||
20 | fileSystems = { | |
21 | "/backup2" = { | |
22 | fsType = "ext4"; | |
23 | device = "UUID=b9425333-f567-435d-94d8-b26c22d93426"; | |
24 | }; | |
25 | }; | |
26 | ||
27 | networking = { | |
28 | firewall.enable = true; | |
29 | interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList | |
30 | (n: ips: { address = ips.ip4; prefixLength = 32; }) | |
31 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.myEnv.servers.backup-2.ips); | |
32 | interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList | |
33 | (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) | |
34 | config.myEnv.servers.backup-2.ips); | |
35 | defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; | |
36 | ||
37 | defaultMailServer = { | |
38 | directDelivery = true; | |
39 | hostName = "eldiron.immae.eu:25"; | |
40 | useTLS = true; | |
41 | useSTARTTLS = true; | |
42 | root = "postmaster@immae.eu"; | |
43 | }; | |
44 | }; | |
45 | ||
46 | services.cron = { | |
47 | mailto = "cron@immae.eu"; | |
48 | enable = true; | |
49 | }; | |
50 | ||
51 | services.rsyncBackup = { | |
52 | mountpoint = "/backup2"; | |
53 | mailto = config.myEnv.rsync_backup.mailto; | |
54 | profiles = config.myEnv.rsync_backup.profiles; | |
55 | ssh_key_public = config.myEnv.rsync_backup.ssh_key.public; | |
56 | ssh_key_private = config.myEnv.rsync_backup.ssh_key.private; | |
57 | }; | |
58 | ||
59 | myServices.monitoring.enable = true; | |
60 | myServices.databasesReplication = { | |
61 | postgresql = { | |
62 | enable = true; | |
63 | base = "/backup2"; | |
64 | hosts = { | |
65 | eldiron = { | |
66 | slot = "backup_2"; | |
67 | connection = "postgresql://backup-2:${config.myEnv.servers.backup-2.ldap.password}@eldiron.immae.eu"; | |
68 | }; | |
69 | }; | |
70 | }; | |
71 | mariadb = { | |
72 | enable = true; | |
73 | base = "/backup2"; | |
74 | hosts = { | |
75 | eldiron = { | |
76 | serverId = 2; | |
77 | # mysql resolves "backup-2" host and checks the ip, but uses /etc/hosts which only contains ip4 | |
78 | host = config.myEnv.servers.eldiron.ips.main.ip4; | |
79 | port = "3306"; | |
80 | user = "backup-2"; | |
81 | password = config.myEnv.servers.backup-2.ldap.password; | |
82 | dumpUser = "root"; | |
83 | dumpPassword = config.myEnv.databases.mysql.systemUsers.root; | |
84 | }; | |
85 | }; | |
86 | }; | |
87 | redis = { | |
88 | enable = true; | |
89 | base = "/backup2"; | |
90 | hosts = { | |
91 | eldiron = { | |
92 | host = "127.0.0.1"; | |
93 | port = "16379"; | |
94 | }; | |
95 | }; | |
96 | }; | |
97 | openldap = { | |
98 | enable = true; | |
99 | base = "/backup2"; | |
100 | hosts = { | |
101 | eldiron = { | |
102 | url = "ldaps://${config.myEnv.ldap.host}:636"; | |
103 | dn = config.myEnv.ldap.replication_dn; | |
104 | password = config.myEnv.ldap.replication_pw; | |
105 | base = config.myEnv.ldap.base; | |
106 | }; | |
107 | }; | |
108 | }; | |
109 | }; | |
110 | ||
111 | # This value determines the NixOS release with which your system is | |
112 | # to be compatible, in order to avoid breaking some software such as | |
113 | # database servers. You should change this only after NixOS release | |
114 | # notes say you should. | |
115 | # https://nixos.org/nixos/manual/release-notes.html | |
116 | system.stateVersion = "19.03"; # Did you read the comment? | |
117 | } |