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