]>
Commit | Line | Data |
---|---|---|
1 | { privateFiles }: | |
2 | { config, pkgs, ... }: | |
3 | { | |
4 | boot.supportedFilesystems = [ "zfs" ]; | |
5 | boot.kernelPackages = pkgs.linuxPackages_latest; | |
6 | myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; | |
7 | ||
8 | networking = { | |
9 | hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4 | |
10 | firewall.enable = true; | |
11 | # 176.9.151.89 declared in nixops -> infra / tools | |
12 | interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList | |
13 | (n: ips: { address = ips.ip4; prefixLength = 32; }) | |
14 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips); | |
15 | interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList | |
16 | (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) | |
17 | config.hostEnv.ips); | |
18 | }; | |
19 | ||
20 | imports = builtins.attrValues (import ../..); | |
21 | ||
22 | boot.kernel.sysctl = { | |
23 | # https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-001.md | |
24 | "net.ipv4.tcp_sack" = 0; | |
25 | }; | |
26 | myServices.buildbot.enable = true; | |
27 | myServices.databases.enable = true; | |
28 | myServices.gitolite.enable = true; | |
29 | myServices.monitoring.enable = true; | |
30 | myServices.irc.enable = true; | |
31 | myServices.pub.enable = true; | |
32 | myServices.tasks.enable = true; | |
33 | myServices.mpd.enable = true; | |
34 | myServices.dns.enable = true; | |
35 | myServices.certificates.enable = true; | |
36 | myServices.websites.enable = true; | |
37 | myServices.mail.enable = true; | |
38 | myServices.ejabberd.enable = true; | |
39 | myServices.vpn.enable = true; | |
40 | services.pure-ftpd.enable = true; | |
41 | services.duplyBackup.enable = true; | |
42 | services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies"; | |
43 | ||
44 | secrets.keys = [ | |
45 | { | |
46 | dest = "rsync_backup/identity"; | |
47 | user = "root"; | |
48 | group = "root"; | |
49 | permissions = "0400"; | |
50 | text = config.myEnv.rsync_backup.ssh_key.private; | |
51 | } | |
52 | ]; | |
53 | programs.ssh.knownHosts.dilion = { | |
54 | hostNames = ["dilion.immae.eu"]; | |
55 | publicKey = let | |
56 | profile = config.myEnv.rsync_backup.profiles.dilion; | |
57 | in | |
58 | "${profile.host_key_type} ${profile.host_key}"; | |
59 | }; | |
60 | ||
61 | deployment = { | |
62 | targetEnv = "hetzner"; | |
63 | hetzner = { | |
64 | robotUser = config.myEnv.hetzner.user; | |
65 | robotPass = config.myEnv.hetzner.pass; | |
66 | mainIPv4 = config.hostEnv.ips.main.ip4; | |
67 | partitions = '' | |
68 | clearpart --all --initlabel --drives=sda,sdb | |
69 | ||
70 | part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda | |
71 | part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb | |
72 | ||
73 | part raid.1 --grow --ondisk=sda | |
74 | part raid.2 --grow --ondisk=sdb | |
75 | ||
76 | raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 | |
77 | ''; | |
78 | }; | |
79 | }; | |
80 | ||
81 | services.cron = { | |
82 | enable = true; | |
83 | mailto = "cron@immae.eu"; | |
84 | systemCronJobs = [ | |
85 | '' | |
86 | # The star after /var/lib/* avoids deleting all folders in case of problem | |
87 | 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 | |
88 | 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "immae.eu.*Recipient address rejected" | |
89 | # Need a way to blacklist properly | |
90 | # 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "NOQUEUE:" | |
91 | 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtp -g "status=bounced" | |
92 | '' | |
93 | ]; | |
94 | }; | |
95 | ||
96 | fileSystems."/var/lib/pub/immae/devtools" = { | |
97 | device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/"; | |
98 | fsType = "fuse"; | |
99 | options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ]; | |
100 | }; | |
101 | environment.systemPackages = [ pkgs.bindfs ]; | |
102 | ||
103 | # This value determines the NixOS release with which your system is | |
104 | # to be compatible, in order to avoid breaking some software such as | |
105 | # database servers. You should change this only after NixOS release | |
106 | # notes say you should. | |
107 | # https://nixos.org/nixos/manual/release-notes.html | |
108 | system.stateVersion = "20.03"; # Did you read the comment? | |
109 | } |