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