2 { config, pkgs, lib, ... }:
6 targetHost = config.hostEnv.ips.main.ip4;
7 substituteOnDestination = true;
10 kernelModules = [ "kvm-intel" ];
11 blacklistedKernelModules = [ "nvidiafb" ];
13 loader.grub.devices = [ "/dev/sda" "/dev/sdb" ];
15 # https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-001.md
16 "net.ipv4.tcp_sack" = 0;
18 supportedFilesystems = [ "zfs" ];
19 kernelParams = ["zfs.zfs_arc_max=6442450944"];
20 kernelPackages = pkgs.linuxPackages_latest;
21 initrd.availableKernelModules = [ "ahci" "sd_mod" ];
23 "/boot/pass.key" = "/boot/pass.key";
26 services.udev.extraRules = ''
27 ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="c8:60:00:56:a0:88", NAME="eth0"
30 powerManagement.cpuFreqGovernor = "powersave";
31 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
34 "/" = { fsType = "zfs"; device = "zpool/root"; };
35 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/e6bb18fb-ff56-4b5f-ae9f-e60d40dc0622"; };
36 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; };
37 "/nix" = { fsType = "zfs"; device = "zpool/root/nix"; };
38 "/tmp" = { fsType = "zfs"; device = "zpool/root/tmp"; };
39 "/var" = { fsType = "zfs"; device = "zpool/root/var"; };
41 swapDevices = [ { label = "swap1"; } { label = "swap2"; } ];
42 hardware.enableRedistributableFirmware = true;
50 hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4
51 firewall.enable = true;
52 # FIXME: on next reboot, remove the /27 and the localCommands
53 interfaces."eth0".ipv4.addresses =
54 pkgs.lib.attrsets.mapAttrsToList
55 (n: ips: { address = ips.ip4; prefixLength = 32; })
56 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips)
57 ++ [ { address = config.hostEnv.ips.main.ip4; prefixLength = 27; } ];
58 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
59 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
61 defaultGateway = "176.9.151.65";
63 # FIXME: Those commands were added by nixops and may not be
65 ip -6 addr add '2a01:4f8:160:3445::/64' dev 'eth0' || true
66 ip -4 route change '176.9.151.64/27' via '176.9.151.65' dev 'eth0' || true
67 ip -6 route add default via 'fe80::1' dev eth0 || true
73 "2a01:4f8:0:a0a1::add:1010"
74 "2a01:4f8:0:a102::add:9999"
75 "2a01:4f8:0:a111::add:9898"
79 imports = builtins.attrValues (import ../..);
81 myServices.buildbot.enable = true;
82 myServices.databases.enable = true;
83 myServices.gitolite.enable = true;
84 myServices.monitoring.enable = true;
85 myServices.irc.enable = true;
86 myServices.pub.enable = true;
87 myServices.tasks.enable = true;
88 myServices.mpd.enable = true;
89 myServices.dns.enable = true;
90 myServices.certificates.enable = true;
91 myServices.websites.enable = true;
92 myServices.mail.enable = true;
93 myServices.ejabberd.enable = true;
94 myServices.vpn.enable = true;
95 services.pure-ftpd.enable = true;
96 services.duplyBackup.enable = false;
97 services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
99 services.netdata.enable = true;
100 services.netdata.config.global."memory mode" = "none";
101 services.netdata.config.health."enabled" = "no";
102 services.netdata.config.web.mode = "none";
103 environment.etc."netdata/stream.conf".text = ''
106 destination = ${config.myEnv.monitoring.netdata_aggregator}
107 api key = ${config.myEnv.monitoring.netdata_keys.eldiron}
111 dest = "zrepl_backup/identity";
114 permissions = "0400";
115 text = config.myEnv.zrepl_backup.ssh_key.private;
118 programs.ssh.knownHosts.dilion = {
119 hostNames = ["dilion.immae.eu"];
121 profile = config.myEnv.rsync_backup.profiles.dilion;
123 "${profile.host_key_type} ${profile.host_key}";
128 mailto = "cron@immae.eu";
131 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "immae.eu.*Recipient address rejected"
132 # Need a way to blacklist properly
133 # 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "NOQUEUE:"
134 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtp -g "status=bounced"
139 fileSystems."/var/lib/pub/immae/devtools" = {
140 device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/";
142 options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ];
144 environment.systemPackages = [ pkgs.bindfs ];
149 redis_dump = pkgs.writeScript "redis-dump" ''
150 #! ${pkgs.stdenv.shell}
151 ${pkgs.redis}/bin/redis-cli bgsave
157 name: "backup-to-dilion"
160 "zpool/root/etc": true
161 "zpool/root/var<": true
163 type: ssh+stdinserver
164 host: dilion.immae.eu
167 identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"}
173 # - type: mysql-lock-tables
174 # dsn: "${config.myEnv.zrepl_backup.mysql.user}:${config.myEnv.zrepl_backup.mysql.password}@tcp(localhost)/"
176 # "zpool/root/var": true
178 # path: ${redis_dump}
179 # err_is_fatal: false
181 # "zpool/root/var": true
189 grid: 24x1h | 7x1d | 4x7d | 6x30d
195 grid: 6x4h | 7x1d | 4x7d | 6x30d
199 # This value determines the NixOS release with which your system is
200 # to be compatible, in order to avoid breaking some software such as
201 # database servers. You should change this only after NixOS release
202 # notes say you should.
203 # https://nixos.org/nixos/manual/release-notes.html
204 system.stateVersion = "20.03"; # Did you read the comment?