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