]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/system/eldiron.nix
Add new machine to nixops
[perso/Immae/Config/Nix.git] / modules / private / system / eldiron.nix
1 { privateFiles }:
2 { config, pkgs, myconfig, ... }:
3 {
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 _module.args.privateFiles = 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") myconfig.env.servers.eldiron.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 myconfig.env.servers.eldiron.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 services.pure-ftpd.enable = true;
37 services.backup.enable = true;
38
39 deployment = {
40 targetEnv = "hetzner";
41 hetzner = {
42 robotUser = myconfig.env.hetzner.user;
43 robotPass = myconfig.env.hetzner.pass;
44 mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
45 partitions = ''
46 clearpart --all --initlabel --drives=sda,sdb
47
48 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
49 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
50
51 part raid.1 --grow --ondisk=sda
52 part raid.2 --grow --ondisk=sdb
53
54 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
55 '';
56 };
57 };
58
59 services.cron = {
60 enable = true;
61 systemCronJobs = [
62 ''
63 # The star after /var/lib/* avoids deleting all folders in case of problem
64 0 3,9,15,21 * * * root rsync -e "ssh -i /root/.ssh/id_charon_vpn" -aAXvz --delete --numeric-ids --super --rsync-path="sudo rsync" /var/lib/* immae@immae.eu: > /dev/null
65 ''
66 ];
67 };
68
69 # This value determines the NixOS release with which your system is
70 # to be compatible, in order to avoid breaking some software such as
71 # database servers. You should change this only after NixOS release
72 # notes say you should.
73 # https://nixos.org/nixos/manual/release-notes.html
74 system.stateVersion = "19.03"; # Did you read the comment?
75 }