]>
Commit | Line | Data |
---|---|---|
1a64deeb | 1 | { config, pkgs, resources, name, lib, nixpkgs, secrets, ... }: |
8415083e | 2 | { |
282c67a1 IB |
3 | # ssh-keyscan backup-2 | nix-shell -p ssh-to-age --run ssh-to-age |
4 | secrets.ageKeys = [ "age1kk3nr27qu42j28mcfdag5lhq0zu2pky7gfanvne8l4z2ctevjpgskmw0sr" ]; | |
4c4652aa IB |
5 | secrets.keys = { |
6 | "rsync_backup/identity" = { | |
bd5c5d4e IB |
7 | user = "backup"; |
8 | group = "backup"; | |
9 | permissions = "0400"; | |
10 | text = config.myEnv.rsync_backup.ssh_key.private; | |
4c4652aa IB |
11 | }; |
12 | "rsync_backup/identity.pub" = { | |
bd5c5d4e IB |
13 | user = "backup"; |
14 | group = "backup"; | |
15 | permissions = "0444"; | |
16 | text = config.myEnv.rsync_backup.ssh_key.public; | |
4c4652aa IB |
17 | }; |
18 | }; | |
8415083e | 19 | boot.kernelPackages = pkgs.linuxPackages_latest; |
ab8f306d | 20 | |
1a64deeb IB |
21 | nixpkgs.config.permittedInsecurePackages = [ |
22 | "python-2.7.18.6" # for nagios-cli | |
23 | ]; | |
24 | ||
25 | imports = | |
26 | [ | |
27 | secrets.nixosModules.users-config-backup-2 | |
28 | (nixpkgs + "/nixos/modules/profiles/qemu-guest.nix") | |
29 | ./databases/mariadb_replication.nix | |
30 | ./databases/openldap_replication.nix | |
31 | ./databases/postgresql_replication.nix | |
32 | ./databases/redis_replication.nix | |
33 | ./mail/relay.nix | |
34 | ./monitoring.nix | |
35 | ]; | |
8415083e | 36 | |
ae485806 IB |
37 | fileSystems = { |
38 | "/backup2" = { | |
39 | fsType = "ext4"; | |
40 | device = "UUID=b9425333-f567-435d-94d8-b26c22d93426"; | |
41 | }; | |
34abd6af | 42 | "/" = { device = "/dev/sda1"; fsType = "ext4"; }; |
ae485806 IB |
43 | }; |
44 | ||
45 | networking = { | |
46 | firewall.enable = true; | |
1a64deeb IB |
47 | interfaces."ens3".ipv4.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList |
48 | (n: ips: map (ip: { address = ip; prefixLength = 32; }) (ips.ip4 or [])) | |
49 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips)); | |
ae485806 IB |
50 | interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList |
51 | (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) | |
619e4f46 | 52 | config.hostEnv.ips); |
dc0e644a | 53 | defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; |
285380fe IB |
54 | }; |
55 | ||
34abd6af IB |
56 | boot.loader.grub.device = "nodev"; |
57 | ||
258dd18b | 58 | security.acme.certs."${name}" = { |
258dd18b IB |
59 | group = config.services.nginx.group; |
60 | }; | |
619e4f46 IB |
61 | services.nginx = { |
62 | enable = true; | |
63 | recommendedOptimisation = true; | |
64 | recommendedGzipSettings = true; | |
65 | recommendedProxySettings = true; | |
66 | }; | |
67 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
68 | ||
4227853a IB |
69 | services.cron = { |
70 | mailto = "cron@immae.eu"; | |
71 | enable = true; | |
72 | }; | |
73 | ||
1a64deeb IB |
74 | myServices.chatonsProperties.hostings.rsync-backup = { |
75 | file.datetime = "2022-08-27T16:00:00"; | |
76 | hosting = { | |
77 | name = "Rsync backups"; | |
78 | description = "Remote initiated rsync backups"; | |
79 | website = "backup-2.v.immae.eu"; | |
80 | status.level = "OK"; | |
81 | status.description = "OK"; | |
82 | registration.load = "OPEN"; | |
83 | install.type = "PACKAGE"; | |
84 | }; | |
85 | software = { | |
86 | name = "rsync"; | |
87 | website = "https://rsync.samba.org/"; | |
88 | license.url = "https://rsync.samba.org/GPL.html"; | |
89 | license.name = "GNU General Public License version 3"; | |
90 | version = pkgs.rsync.version; | |
91 | source.url = "https://github.com/WayneD/rsync"; | |
92 | }; | |
93 | }; | |
94 | ||
285380fe IB |
95 | services.rsyncBackup = { |
96 | mountpoint = "/backup2"; | |
ab8f306d | 97 | profiles = config.myEnv.rsync_backup.profiles; |
bd5c5d4e IB |
98 | ssh_key_public = config.secrets.fullPaths."rsync_backup/identity.pub"; |
99 | ssh_key_private = config.secrets.fullPaths."rsync_backup/identity"; | |
ae485806 IB |
100 | }; |
101 | ||
deca5e9b | 102 | myServices.mailRelay.enable = true; |
619e4f46 | 103 | myServices.mailBackup.enable = true; |
9f202523 | 104 | myServices.monitoring.enable = true; |
ec9b6564 IB |
105 | myServices.databasesReplication = { |
106 | postgresql = { | |
107 | enable = true; | |
108 | base = "/backup2"; | |
9f16e659 | 109 | mainPackage = pkgs.postgresql; |
ec9b6564 IB |
110 | hosts = { |
111 | eldiron = { | |
112 | slot = "backup_2"; | |
619e4f46 | 113 | connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu"; |
9f16e659 | 114 | package = pkgs.postgresql; |
ec9b6564 IB |
115 | }; |
116 | }; | |
117 | }; | |
9f6a7862 IB |
118 | mariadb = { |
119 | enable = true; | |
120 | base = "/backup2"; | |
121 | hosts = { | |
122 | eldiron = { | |
123 | serverId = 2; | |
124 | # mysql resolves "backup-2" host and checks the ip, but uses /etc/hosts which only contains ip4 | |
1a64deeb IB |
125 | host = lib.head config.myEnv.servers.eldiron.ips.main.ip4; |
126 | port = config.myEnv.databases.mysql.port; | |
9f6a7862 | 127 | user = "backup-2"; |
619e4f46 | 128 | password = config.hostEnv.ldap.password; |
9f6a7862 | 129 | dumpUser = "root"; |
ab8f306d | 130 | dumpPassword = config.myEnv.databases.mysql.systemUsers.root; |
9f6a7862 IB |
131 | }; |
132 | }; | |
133 | }; | |
dded6699 IB |
134 | redis = { |
135 | enable = true; | |
136 | base = "/backup2"; | |
137 | hosts = { | |
138 | eldiron = { | |
139 | host = "127.0.0.1"; | |
140 | port = "16379"; | |
141 | }; | |
142 | }; | |
143 | }; | |
16b80abd IB |
144 | openldap = { |
145 | enable = true; | |
146 | base = "/backup2"; | |
147 | hosts = { | |
148 | eldiron = { | |
ab8f306d IB |
149 | url = "ldaps://${config.myEnv.ldap.host}:636"; |
150 | dn = config.myEnv.ldap.replication_dn; | |
151 | password = config.myEnv.ldap.replication_pw; | |
152 | base = config.myEnv.ldap.base; | |
16b80abd IB |
153 | }; |
154 | }; | |
155 | }; | |
ec9b6564 IB |
156 | }; |
157 | ||
8415083e IB |
158 | # This value determines the NixOS release with which your system is |
159 | # to be compatible, in order to avoid breaking some software such as | |
160 | # database servers. You should change this only after NixOS release | |
161 | # notes say you should. | |
162 | # https://nixos.org/nixos/manual/release-notes.html | |
1a64deeb | 163 | system.stateVersion = "23.05"; # Did you read the comment? |
8415083e | 164 | } |