]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/system/eldiron.nix
df4018768bdd59ec64206ecdf50d85ca4e871865
[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.irc.enable = true;
28 myServices.pub.enable = true;
29 myServices.tasks.enable = true;
30 services.pure-ftpd.enable = true;
31
32 deployment = {
33 targetEnv = "hetzner";
34 hetzner = {
35 robotUser = myconfig.env.hetzner.user;
36 robotPass = myconfig.env.hetzner.pass;
37 mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4;
38 partitions = ''
39 clearpart --all --initlabel --drives=sda,sdb
40
41 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
42 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
43
44 part raid.1 --grow --ondisk=sda
45 part raid.2 --grow --ondisk=sdb
46
47 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
48 '';
49 };
50 };
51
52 services.cron = {
53 enable = true;
54 systemCronJobs = [
55 ''
56 # The star after /var/lib/* avoids deleting all folders in case of problem
57 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
58 ''
59 ];
60 };
61
62 # This value determines the NixOS release with which your system is
63 # to be compatible, in order to avoid breaking some software such as
64 # database servers. You should change this only after NixOS release
65 # notes say you should.
66 # https://nixos.org/nixos/manual/release-notes.html
67 system.stateVersion = "19.03"; # Did you read the comment?
68 }