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; };
38 # zpool/: acltype=posixacl ; xattr=sa ; atime=off ; mountpoint=legacy
39 # zpool/root: encryption=on ; keyformat=passphrase ; keylocation=file:///boot/pass.key
40 # zpool/root/var: atime=on
41 # zfast/: acltype=posixacl ; xattr=sa ; atime=off ; mountpoint=legacy
42 # zfast/root: encryption=on ; keyformat=passphrase ; keylocation=file:///boot/pass.key
45 # zfast/root/tmp: async=disabled
46 # zfast/root/var: atime=on
47 # zfast/root/var/lib: ø
48 # zfast/root/var/lib/mysql: logbias=throughput ; atime=off ; primarycache=metadata
49 # zfast/root/var/lib/postgresql: recordsize=8K ; atime=off ; logbias=throughput
50 # zfast/root/var/lib/postgresql/11.0: ø
51 # zfast/root/var/lib/postgresql/11.0/pg_wal: ø
52 "/" = { fsType = "zfs"; device = "zpool/root"; };
53 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/e6bb18fb-ff56-4b5f-ae9f-e60d40dc0622"; };
54 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; };
55 "/nix" = { fsType = "zfs"; device = "zfast/root/nix"; };
56 "/tmp" = { fsType = "zfs"; device = "zfast/root/tmp"; };
57 "/var" = { fsType = "zfs"; device = "zpool/root/var"; };
58 "/var/lib/mysql" = { fsType = "zfs"; device = "zfast/root/var/lib/mysql"; };
59 "/var/lib/postgresql" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql"; };
60 "/var/lib/postgresql/11.0" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql/11.0"; };
61 "/var/lib/postgresql/11.0/pg_wal" = { fsType = "zfs"; device = "zfast/root/var/lib/postgresql/11.0/pg_wal"; };
63 swapDevices = [ { label = "swap1"; } { label = "swap2"; } ];
64 hardware.enableRedistributableFirmware = true;
72 hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4
73 firewall.enable = true;
74 # FIXME: on next reboot, remove the /27 and the localCommands
75 interfaces."eth0".ipv4.addresses =
76 pkgs.lib.attrsets.mapAttrsToList
77 (n: ips: { address = ips.ip4; prefixLength = 32; })
78 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips)
79 ++ [ { address = config.hostEnv.ips.main.ip4; prefixLength = 27; } ];
80 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
81 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
83 defaultGateway = "176.9.151.65";
85 # FIXME: Those commands were added by nixops and may not be
87 ip -6 addr add '2a01:4f8:160:3445::/64' dev 'eth0' || true
88 ip -4 route change '176.9.151.64/27' via '176.9.151.65' dev 'eth0' || true
89 ip -6 route add default via 'fe80::1' dev eth0 || true
95 "2a01:4f8:0:a0a1::add:1010"
96 "2a01:4f8:0:a102::add:9999"
97 "2a01:4f8:0:a111::add:9898"
101 imports = builtins.attrValues (import ../..);
103 myServices.buildbot.enable = true;
104 myServices.databases.enable = true;
105 myServices.gitolite.enable = true;
106 myServices.monitoring.enable = true;
107 myServices.irc.enable = true;
108 myServices.pub.enable = true;
109 myServices.tasks.enable = true;
110 myServices.mpd.enable = true;
111 myServices.dns.enable = true;
112 myServices.certificates.enable = true;
113 myServices.websites.enable = true;
114 myServices.mail.enable = true;
115 myServices.ejabberd.enable = true;
116 myServices.vpn.enable = true;
117 services.pure-ftpd.enable = true;
118 services.duplyBackup.enable = false;
119 services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
121 services.netdata.enable = true;
122 services.netdata.config.global."memory mode" = "none";
123 services.netdata.config.health."enabled" = "no";
124 services.netdata.config.web.mode = "none";
125 users.users."${config.services.netdata.user}".extraGroups = [ "keys" ];
126 environment.etc."netdata/stream.conf".source = "/var/secrets/netdata-stream.conf";
129 dest = "netdata-stream.conf";
130 user = config.services.netdata.user;
131 group = config.services.netdata.group;
132 permissions = "0400";
136 destination = ${config.myEnv.monitoring.netdata_aggregator}
137 api key = ${config.myEnv.monitoring.netdata_keys.eldiron}
141 dest = "zrepl_backup/identity";
144 permissions = "0400";
145 text = config.myEnv.zrepl_backup.ssh_key.private;
148 programs.ssh.knownHosts.dilion = {
149 hostNames = ["dilion.immae.eu"];
151 profile = config.myEnv.rsync_backup.profiles.dilion;
153 "${profile.host_key_type} ${profile.host_key}";
158 mailto = "cron@immae.eu";
161 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "immae.eu.*Recipient address rejected"
162 # Need a way to blacklist properly
163 # 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "NOQUEUE:"
164 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtp -g "status=bounced"
169 fileSystems."/var/lib/pub/immae/devtools" = {
170 device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/";
172 options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ];
174 environment.systemPackages = [ pkgs.bindfs ];
179 redis_dump = pkgs.writeScript "redis-dump" ''
180 #! ${pkgs.stdenv.shell}
181 ${pkgs.redis}/bin/redis-cli bgsave
187 name: "backup-to-dilion"
190 "zpool/root/etc": true
191 "zpool/root/var<": true
193 type: ssh+stdinserver
194 host: dilion.immae.eu
197 identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"}
203 # - type: mysql-lock-tables
204 # dsn: "${config.myEnv.zrepl_backup.mysql.user}:${config.myEnv.zrepl_backup.mysql.password}@tcp(localhost)/"
206 # "zpool/root/var": true
208 # path: ${redis_dump}
209 # err_is_fatal: false
211 # "zpool/root/var": true
219 grid: 24x1h | 7x1d | 4x7d | 6x30d
225 grid: 6x4h | 7x1d | 4x7d | 6x30d
229 # This value determines the NixOS release with which your system is
230 # to be compatible, in order to avoid breaking some software such as
231 # database servers. You should change this only after NixOS release
232 # notes say you should.
233 # https://nixos.org/nixos/manual/release-notes.html
234 system.stateVersion = "20.03"; # Did you read the comment?