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 # 176.9.151.89 declared in nixops -> infra / tools
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";
101 dest = "zrepl_backup/identity";
104 permissions = "0400";
105 text = config.myEnv.zrepl_backup.ssh_key.private;
108 programs.ssh.knownHosts.dilion = {
109 hostNames = ["dilion.immae.eu"];
111 profile = config.myEnv.rsync_backup.profiles.dilion;
113 "${profile.host_key_type} ${profile.host_key}";
118 mailto = "cron@immae.eu";
121 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "immae.eu.*Recipient address rejected"
122 # Need a way to blacklist properly
123 # 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtpd -g "NOQUEUE:"
124 0 0 * * * root journalctl -q --since="25 hours ago" -u postfix -t postfix/smtp -g "status=bounced"
129 fileSystems."/var/lib/pub/immae/devtools" = {
130 device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/";
132 options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ];
134 environment.systemPackages = [ pkgs.bindfs ];
139 redis_dump = pkgs.writeScript "redis-dump" ''
140 #! ${pkgs.stdenv.shell}
141 ${pkgs.redis}/bin/redis-cli bgsave
147 name: "backup-to-dilion"
150 "zpool/root/etc": true
151 "zpool/root/var<": true
153 type: ssh+stdinserver
154 host: dilion.immae.eu
157 identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"}
163 - type: mysql-lock-tables
164 dsn: "${config.myEnv.zrepl_backup.mysql.user}:${config.myEnv.zrepl_backup.mysql.password}@tcp(localhost)/"
166 "zpool/root/var": true
171 "zpool/root/var": true
176 - type: not_replicated
180 grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d
186 grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d
190 # This value determines the NixOS release with which your system is
191 # to be compatible, in order to avoid breaking some software such as
192 # database servers. You should change this only after NixOS release
193 # notes say you should.
194 # https://nixos.org/nixos/manual/release-notes.html
195 system.stateVersion = "20.03"; # Did you read the comment?