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