1 { config, pkgs, resources, name, lib, nixpkgs, secrets, ... }:
3 # ssh-keyscan backup-2 | nix-shell -p ssh-to-age --run ssh-to-age
4 secrets.ageKeys = [ "age1kk3nr27qu42j28mcfdag5lhq0zu2pky7gfanvne8l4z2ctevjpgskmw0sr" ];
6 "rsync_backup/identity" = {
10 text = config.myEnv.rsync_backup.ssh_key.private;
12 "rsync_backup/identity.pub" = {
16 text = config.myEnv.rsync_backup.ssh_key.public;
19 boot.kernelPackages = pkgs.linuxPackages_latest;
21 nixpkgs.config.permittedInsecurePackages = [
22 "python-2.7.18.6" # for nagios-cli
27 secrets.nixosModules.users-config-backup-2
28 (nixpkgs + "/nixos/modules/profiles/qemu-guest.nix")
29 ./databases/mariadb_replication.nix
30 ./databases/openldap_replication.nix
31 ./databases/postgresql_replication.nix
32 ./databases/redis_replication.nix
40 device = "UUID=b9425333-f567-435d-94d8-b26c22d93426";
42 "/" = { device = "/dev/sda1"; fsType = "ext4"; };
46 firewall.enable = true;
47 interfaces."ens3".ipv4.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
48 (n: ips: map (ip: { address = ip; prefixLength = 32; }) (ips.ip4 or []))
49 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips));
50 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
51 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
53 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
56 boot.loader.grub.device = "nodev";
58 security.acme.certs."${name}" = {
59 group = config.services.nginx.group;
63 recommendedOptimisation = true;
64 recommendedGzipSettings = true;
65 recommendedProxySettings = true;
67 networking.firewall.allowedTCPPorts = [ 80 443 ];
70 mailto = "cron@immae.eu";
74 myServices.chatonsProperties.hostings.rsync-backup = {
75 file.datetime = "2022-08-27T16:00:00";
77 name = "Rsync backups";
78 description = "Remote initiated rsync backups";
79 website = "backup-2.v.immae.eu";
81 status.description = "OK";
82 registration.load = "OPEN";
83 install.type = "PACKAGE";
87 website = "https://rsync.samba.org/";
88 license.url = "https://rsync.samba.org/GPL.html";
89 license.name = "GNU General Public License version 3";
90 version = pkgs.rsync.version;
91 source.url = "https://github.com/WayneD/rsync";
95 services.rsyncBackup = {
96 mountpoint = "/backup2";
97 profiles = config.myEnv.rsync_backup.profiles;
98 ssh_key_public = config.secrets.fullPaths."rsync_backup/identity.pub";
99 ssh_key_private = config.secrets.fullPaths."rsync_backup/identity";
102 myServices.mailRelay.enable = true;
103 myServices.mailBackup.enable = true;
104 myServices.monitoring.enable = true;
105 myServices.databasesReplication = {
109 mainPackage = pkgs.postgresql;
113 connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu";
114 package = pkgs.postgresql;
124 # mysql resolves "backup-2" host and checks the ip, but uses /etc/hosts which only contains ip4
125 host = lib.head config.myEnv.servers.eldiron.ips.main.ip4;
126 port = config.myEnv.databases.mysql.port;
128 password = config.hostEnv.ldap.password;
130 dumpPassword = config.myEnv.databases.mysql.systemUsers.root;
149 url = "ldaps://${config.myEnv.ldap.host}:636";
150 dn = config.myEnv.ldap.replication_dn;
151 password = config.myEnv.ldap.replication_pw;
152 base = config.myEnv.ldap.base;
158 # This value determines the NixOS release with which your system is
159 # to be compatible, in order to avoid breaking some software such as
160 # database servers. You should change this only after NixOS release
161 # notes say you should.
162 # https://nixos.org/nixos/manual/release-notes.html
163 system.stateVersion = "23.05"; # Did you read the comment?