]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/system/backup-2.nix
1c5b7d84b383cebbd86a839c3872d5f1dd670d7c
[perso/Immae/Config/Nix.git] / modules / private / system / backup-2.nix
1 { privateFiles }:
2 { config, pkgs, myconfig, resources, ... }:
3 {
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 _module.args.privateFiles = privateFiles;
6 imports = builtins.attrValues (import ../..);
7
8 deployment = {
9 targetEnv = "hetznerCloud";
10 hetznerCloud = {
11 authToken = myconfig.env.hetznerCloud.authToken;
12 datacenter = "hel1-dc2";
13 location ="hel1";
14 serverType = "cx11";
15 };
16 };
17
18 fileSystems = {
19 "/backup2" = {
20 fsType = "ext4";
21 device = "UUID=b9425333-f567-435d-94d8-b26c22d93426";
22 };
23 };
24
25 networking = {
26 firewall.enable = true;
27 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
28 (n: ips: { address = ips.ip4; prefixLength = 32; })
29 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.backup-2.ips);
30 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
31 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
32 myconfig.env.servers.backup-2.ips);
33
34 defaultMailServer = {
35 directDelivery = true;
36 hostName = "eldiron.immae.eu:25";
37 useTLS = true;
38 useSTARTTLS = true;
39 root = "postmaster@immae.eu";
40 };
41 };
42
43 services.rsyncBackup = {
44 mountpoint = "/backup2";
45 mailto = myconfig.env.rsync_backup.mailto;
46 profiles = myconfig.env.rsync_backup.profiles;
47 ssh_key_public = myconfig.env.rsync_backup.ssh_key.public;
48 ssh_key_private = myconfig.env.rsync_backup.ssh_key.private;
49 };
50
51 myServices.databasesReplication = {
52 postgresql = {
53 enable = true;
54 base = "/backup2";
55 hosts = {
56 eldiron = {
57 slot = "backup_2";
58 connection = "postgresql://backup-2:${myconfig.env.ldap.backup-2.password}@eldiron.immae.eu";
59 };
60 };
61 };
62 };
63
64 # This value determines the NixOS release with which your system is
65 # to be compatible, in order to avoid breaking some software such as
66 # database servers. You should change this only after NixOS release
67 # notes say you should.
68 # https://nixos.org/nixos/manual/release-notes.html
69 system.stateVersion = "19.03"; # Did you read the comment?
70 }