]>
Commit | Line | Data |
---|---|---|
1 | { privateFiles }: | |
2 | { config, pkgs, resources, name, ... }: | |
3 | { | |
4 | boot.kernelPackages = pkgs.linuxPackages_latest; | |
5 | myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; | |
6 | ||
7 | imports = builtins.attrValues (import ../..); | |
8 | ||
9 | deployment = { | |
10 | targetEnv = "hetznerCloud"; | |
11 | hetznerCloud = { | |
12 | authToken = config.myEnv.hetznerCloud.authToken; | |
13 | datacenter = "hel1-dc2"; | |
14 | location ="hel1"; | |
15 | serverType = "cx11"; | |
16 | }; | |
17 | }; | |
18 | ||
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; }) | |
30 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips); | |
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 [])) | |
33 | config.hostEnv.ips); | |
34 | defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; | |
35 | }; | |
36 | ||
37 | myServices.certificates.enable = true; | |
38 | security.acme.certs."${name}" = { | |
39 | user = config.services.nginx.user; | |
40 | group = config.services.nginx.group; | |
41 | }; | |
42 | services.nginx = { | |
43 | enable = true; | |
44 | recommendedOptimisation = true; | |
45 | recommendedGzipSettings = true; | |
46 | recommendedProxySettings = true; | |
47 | }; | |
48 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
49 | ||
50 | services.cron = { | |
51 | mailto = "cron@immae.eu"; | |
52 | enable = true; | |
53 | }; | |
54 | ||
55 | services.rsyncBackup = { | |
56 | mountpoint = "/backup2"; | |
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; | |
60 | }; | |
61 | ||
62 | myServices.mailRelay.enable = true; | |
63 | myServices.mailBackup.enable = true; | |
64 | myServices.monitoring.enable = true; | |
65 | myServices.databasesReplication = { | |
66 | postgresql = { | |
67 | enable = true; | |
68 | base = "/backup2"; | |
69 | mainPackage = pkgs.postgresql; | |
70 | hosts = { | |
71 | eldiron = { | |
72 | slot = "backup_2"; | |
73 | connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu"; | |
74 | package = pkgs.postgresql; | |
75 | }; | |
76 | }; | |
77 | }; | |
78 | mariadb = { | |
79 | enable = true; | |
80 | base = "/backup2"; | |
81 | hosts = { | |
82 | eldiron = { | |
83 | serverId = 2; | |
84 | # mysql resolves "backup-2" host and checks the ip, but uses /etc/hosts which only contains ip4 | |
85 | host = config.myEnv.servers.eldiron.ips.main.ip4; | |
86 | port = "3306"; | |
87 | user = "backup-2"; | |
88 | password = config.hostEnv.ldap.password; | |
89 | dumpUser = "root"; | |
90 | dumpPassword = config.myEnv.databases.mysql.systemUsers.root; | |
91 | }; | |
92 | }; | |
93 | }; | |
94 | redis = { | |
95 | enable = true; | |
96 | base = "/backup2"; | |
97 | hosts = { | |
98 | eldiron = { | |
99 | host = "127.0.0.1"; | |
100 | port = "16379"; | |
101 | }; | |
102 | }; | |
103 | }; | |
104 | openldap = { | |
105 | enable = true; | |
106 | base = "/backup2"; | |
107 | hosts = { | |
108 | eldiron = { | |
109 | url = "ldaps://${config.myEnv.ldap.host}:636"; | |
110 | dn = config.myEnv.ldap.replication_dn; | |
111 | password = config.myEnv.ldap.replication_pw; | |
112 | base = config.myEnv.ldap.base; | |
113 | }; | |
114 | }; | |
115 | }; | |
116 | }; | |
117 | ||
118 | # This value determines the NixOS release with which your system is | |
119 | # to be compatible, in order to avoid breaking some software such as | |
120 | # database servers. You should change this only after NixOS release | |
121 | # notes say you should. | |
122 | # https://nixos.org/nixos/manual/release-notes.html | |
123 | system.stateVersion = "20.03"; # Did you read the comment? | |
124 | } |