]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/system/eldiron.nix
Fix rsync compression
[perso/Immae/Config/Nix.git] / modules / private / system / eldiron.nix
1 { privateFiles }:
2 { config, pkgs, ... }:
3 {
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
6
7 networking = {
8 firewall.enable = true;
9 # 176.9.151.89 declared in nixops -> infra / tools
10 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
11 (n: ips: { address = ips.ip4; prefixLength = 32; })
12 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
13 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
14 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
15 config.hostEnv.ips);
16 };
17
18 imports = builtins.attrValues (import ../..);
19
20 boot.kernel.sysctl = {
21 # https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-001.md
22 "net.ipv4.tcp_sack" = 0;
23 };
24 myServices.buildbot.enable = true;
25 myServices.databases.enable = true;
26 myServices.gitolite.enable = true;
27 myServices.monitoring.enable = true;
28 myServices.irc.enable = true;
29 myServices.pub.enable = true;
30 myServices.tasks.enable = true;
31 myServices.mpd.enable = true;
32 myServices.dns.enable = true;
33 myServices.certificates.enable = true;
34 myServices.websites.enable = true;
35 myServices.mail.enable = true;
36 myServices.ejabberd.enable = true;
37 services.pure-ftpd.enable = true;
38 services.duplyBackup.enable = true;
39 services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
40
41 deployment = {
42 targetEnv = "hetzner";
43 hetzner = {
44 robotUser = config.myEnv.hetzner.user;
45 robotPass = config.myEnv.hetzner.pass;
46 mainIPv4 = config.hostEnv.ips.main.ip4;
47 partitions = ''
48 clearpart --all --initlabel --drives=sda,sdb
49
50 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
51 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
52
53 part raid.1 --grow --ondisk=sda
54 part raid.2 --grow --ondisk=sdb
55
56 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
57 '';
58 };
59 };
60
61 services.cron = {
62 enable = true;
63 mailto = "cron@immae.eu";
64 systemCronJobs = [
65 ''
66 # The star after /var/lib/* avoids deleting all folders in case of problem
67 0 3,9,15,21 * * * root rsync -e "ssh -i /root/.ssh/id_charon_vpn" --new-compress -aAXv --delete --numeric-ids --super --rsync-path="sudo rsync" /var/lib/* immae@immae.eu: > /dev/null
68 ''
69 ];
70 };
71
72 # This value determines the NixOS release with which your system is
73 # to be compatible, in order to avoid breaking some software such as
74 # database servers. You should change this only after NixOS release
75 # notes say you should.
76 # https://nixos.org/nixos/manual/release-notes.html
77 system.stateVersion = "19.03"; # Did you read the comment?
78 }