]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - private/system/eldiron.nix
Add tools
[perso/Immae/Config/Nix.git] / 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 myServices.vpn.enable = true;
38 services.pure-ftpd.enable = true;
39 services.duplyBackup.enable = true;
40 services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
41
42 secrets.keys = [
43 {
44 dest = "rsync_backup/identity";
45 user = "root";
46 group = "root";
47 permissions = "0400";
48 text = config.myEnv.rsync_backup.ssh_key.private;
49 }
50 ];
51 programs.ssh.knownHosts.dilion = {
52 hostNames = ["dilion.immae.eu"];
53 publicKey = let
54 profile = config.myEnv.rsync_backup.profiles.dilion;
55 in
56 "${profile.host_key_type} ${profile.host_key}";
57 };
58
59 deployment = {
60 targetEnv = "hetzner";
61 hetzner = {
62 robotUser = config.myEnv.hetzner.user;
63 robotPass = config.myEnv.hetzner.pass;
64 mainIPv4 = config.hostEnv.ips.main.ip4;
65 partitions = ''
66 clearpart --all --initlabel --drives=sda,sdb
67
68 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
69 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
70
71 part raid.1 --grow --ondisk=sda
72 part raid.2 --grow --ondisk=sdb
73
74 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
75 '';
76 };
77 };
78
79 services.cron = {
80 enable = true;
81 mailto = "cron@immae.eu";
82 systemCronJobs = [
83 ''
84 # The star after /var/lib/* avoids deleting all folders in case of problem
85 0 3,9,15,21 * * * root rsync -e "ssh -i /var/secrets/rsync_backup/identity" --new-compress -aAXv --delete --numeric-ids --super --rsync-path="sudo rsync" /var/lib/* backup@dilion.immae.eu: > /dev/null
86 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -g "immae.eu.*Recipient address rejected"
87 ''
88 ];
89 };
90
91 # This value determines the NixOS release with which your system is
92 # to be compatible, in order to avoid breaking some software such as
93 # database servers. You should change this only after NixOS release
94 # notes say you should.
95 # https://nixos.org/nixos/manual/release-notes.html
96 system.stateVersion = "20.03"; # Did you read the comment?
97 }