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