2 { config, pkgs, lib, ... }:
4 boot.supportedFilesystems = [ "zfs" ];
5 boot.kernelParams = ["zfs.zfs_arc_max=6442450944"];
6 boot.kernelPackages = pkgs.linuxPackages_latest;
7 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
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"; };
17 boot.initrd.secrets = {
18 "/boot/pass.key" = "/boot/pass.key";
27 hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4
28 firewall.enable = true;
29 # 176.9.151.89 declared in nixops -> infra / tools
30 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
31 (n: ips: { address = ips.ip4; prefixLength = 32; })
32 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
33 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
34 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
38 imports = builtins.attrValues (import ../..);
40 boot.kernel.sysctl = {
41 # https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-001.md
42 "net.ipv4.tcp_sack" = 0;
44 myServices.buildbot.enable = true;
45 myServices.databases.enable = true;
46 myServices.gitolite.enable = true;
47 myServices.monitoring.enable = true;
48 myServices.irc.enable = true;
49 myServices.pub.enable = true;
50 myServices.tasks.enable = true;
51 myServices.mpd.enable = true;
52 myServices.dns.enable = true;
53 myServices.certificates.enable = true;
54 myServices.websites.enable = true;
55 myServices.mail.enable = true;
56 myServices.ejabberd.enable = true;
57 myServices.vpn.enable = true;
58 services.pure-ftpd.enable = true;
59 services.duplyBackup.enable = true;
60 services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
64 dest = "zrepl_backup/identity";
68 text = config.myEnv.zrepl_backup.ssh_key.private;
71 programs.ssh.knownHosts.dilion = {
72 hostNames = ["dilion.immae.eu"];
74 profile = config.myEnv.rsync_backup.profiles.dilion;
76 "${profile.host_key_type} ${profile.host_key}";
80 targetEnv = "hetzner";
82 robotUser = config.myEnv.hetzner.user;
83 robotPass = config.myEnv.hetzner.pass;
84 mainIPv4 = config.hostEnv.ips.main.ip4;
86 clearpart --all --initlabel --drives=sda,sdb
88 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
89 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
91 part raid.1 --grow --ondisk=sda
92 part raid.2 --grow --ondisk=sdb
94 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
101 mailto = "cron@immae.eu";
104 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "immae.eu.*Recipient address rejected"
105 # Need a way to blacklist properly
106 # 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "NOQUEUE:"
107 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtp -g "status=bounced"
112 fileSystems."/var/lib/pub/immae/devtools" = {
113 device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/";
115 options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ];
117 environment.systemPackages = [ pkgs.bindfs ];
122 redis_dump = pkgs.writeScript "redis-dump" ''
123 #! ${pkgs.stdenv.shell}
124 ${pkgs.redis}/bin/redis-cli bgsave
130 name: "backup-to-dilion"
133 "zpool/root/etc": true
134 "zpool/root/var<": true
136 type: ssh+stdinserver
137 host: dilion.immae.eu
140 identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"}
146 - type: mysql-lock-tables
147 dsn: "${config.myEnv.zrepl_backup.mysql.user}:${config.myEnv.zrepl_backup.mysql.password}@tcp(localhost)/"
149 "zpool/root/var": true
154 "zpool/root/var": true
159 - type: not_replicated
163 grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d
169 grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d
173 # This value determines the NixOS release with which your system is
174 # to be compatible, in order to avoid breaking some software such as
175 # database servers. You should change this only after NixOS release
176 # notes say you should.
177 # https://nixos.org/nixos/manual/release-notes.html
178 system.stateVersion = "20.03"; # Did you read the comment?