1 { config, pkgs, resources, name, ... }:
5 targetHost = config.hostEnv.ips.main.ip4;
6 substituteOnDestination = true;
8 # ssh-keyscan backup-2 | nix-shell -p ssh-to-age --run ssh-to-age
9 secrets.ageKeys = [ "age1kk3nr27qu42j28mcfdag5lhq0zu2pky7gfanvne8l4z2ctevjpgskmw0sr" ];
12 dest = "rsync_backup/identity";
16 text = config.myEnv.rsync_backup.ssh_key.private;
19 dest = "rsync_backup/identity.pub";
23 text = config.myEnv.rsync_backup.ssh_key.public;
26 boot.kernelPackages = pkgs.linuxPackages_latest;
27 myEnv = import ../../../nixops/secrets/environment.nix;
29 imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ] ++ builtins.attrValues (import ../..);
34 device = "UUID=b9425333-f567-435d-94d8-b26c22d93426";
36 "/" = { device = "/dev/sda1"; fsType = "ext4"; };
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 []))
47 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
50 boot.loader.grub.device = "nodev";
52 myServices.certificates.enable = true;
53 security.acme.certs."${name}" = {
54 user = config.services.nginx.user;
55 group = config.services.nginx.group;
59 recommendedOptimisation = true;
60 recommendedGzipSettings = true;
61 recommendedProxySettings = true;
63 networking.firewall.allowedTCPPorts = [ 80 443 ];
66 mailto = "cron@immae.eu";
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";
77 myServices.mailRelay.enable = true;
78 myServices.mailBackup.enable = true;
79 myServices.monitoring.enable = true;
80 myServices.databasesReplication = {
84 mainPackage = pkgs.postgresql;
88 connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu";
89 package = pkgs.postgresql;
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;
103 password = config.hostEnv.ldap.password;
105 dumpPassword = config.myEnv.databases.mysql.systemUsers.root;
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;
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?