]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/system/eldiron.nix
Disable duply backups
[perso/Immae/Config/Nix.git] / modules / private / system / eldiron.nix
CommitLineData
f807d917 1{ privateFiles }:
7e214bf9 2{ config, pkgs, lib, ... }:
f807d917 3{
34abd6af
IB
4 deployment = {
5 targetUser = "root";
6 targetHost = config.hostEnv.ips.main.ip4;
7 substituteOnDestination = true;
8 };
9 boot = {
10 kernelModules = [ "kvm-intel" ];
11 blacklistedKernelModules = [ "nvidiafb" ];
12 loader.timeout = 1;
13 loader.grub.devices = [ "/dev/sda" "/dev/sdb" ];
14 kernel.sysctl = {
15 # https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-001.md
16 "net.ipv4.tcp_sack" = 0;
17 };
18 supportedFilesystems = [ "zfs" ];
19 kernelParams = ["zfs.zfs_arc_max=6442450944"];
20 kernelPackages = pkgs.linuxPackages_latest;
21 initrd.availableKernelModules = [ "ahci" "sd_mod" ];
22 initrd.secrets = {
23 "/boot/pass.key" = "/boot/pass.key";
24 };
25 };
26 services.udev.extraRules = ''
27 ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="c8:60:00:56:a0:88", NAME="eth0"
28 '';
29 nix.maxJobs = 8;
30 powerManagement.cpuFreqGovernor = "powersave";
ab8f306d 31 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
f807d917 32
7e214bf9 33 fileSystems = {
34abd6af 34 "/" = { fsType = "zfs"; device = "zpool/root"; };
7e214bf9
IB
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"; };
40 };
34abd6af
IB
41 swapDevices = [ { label = "swap1"; } { label = "swap2"; } ];
42 hardware.enableRedistributableFirmware = true;
7e214bf9
IB
43
44 services.zfs = {
7e214bf9
IB
45 autoScrub = {
46 enable = true;
47 };
48 };
f807d917 49 networking = {
31e11cdf 50 hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4
f807d917
IB
51 firewall.enable = true;
52 # 176.9.151.89 declared in nixops -> infra / tools
34abd6af
IB
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; } ];
f807d917
IB
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 []))
619e4f46 60 config.hostEnv.ips);
34abd6af
IB
61 defaultGateway = "176.9.151.65";
62 localCommands = ''
63 # FIXME: Those commands were added by nixops and may not be
64 # actually needed
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
68 '';
69 nameservers = [
70 "213.133.98.98"
71 "213.133.99.99"
72 "213.133.100.100"
73 "2a01:4f8:0:a0a1::add:1010"
74 "2a01:4f8:0:a102::add:9999"
75 "2a01:4f8:0:a111::add:9898"
76 ];
f807d917
IB
77 };
78
79 imports = builtins.attrValues (import ../..);
80
81 myServices.buildbot.enable = true;
82 myServices.databases.enable = true;
83 myServices.gitolite.enable = true;
3bc32d9e 84 myServices.monitoring.enable = true;
f807d917
IB
85 myServices.irc.enable = true;
86 myServices.pub.enable = true;
87 myServices.tasks.enable = true;
8415083e
IB
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;
3f453c7d 93 myServices.ejabberd.enable = true;
ea9c6fe8 94 myServices.vpn.enable = true;
f807d917 95 services.pure-ftpd.enable = true;
5b42284e 96 services.duplyBackup.enable = false;
213c323a 97 services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies";
f807d917 98
8bf83d7a
IB
99 secrets.keys = [
100 {
5dda316b 101 dest = "zrepl_backup/identity";
8bf83d7a
IB
102 user = "root";
103 group = "root";
104 permissions = "0400";
5dda316b 105 text = config.myEnv.zrepl_backup.ssh_key.private;
8bf83d7a
IB
106 }
107 ];
108 programs.ssh.knownHosts.dilion = {
109 hostNames = ["dilion.immae.eu"];
110 publicKey = let
111 profile = config.myEnv.rsync_backup.profiles.dilion;
112 in
113 "${profile.host_key_type} ${profile.host_key}";
114 };
115
f807d917
IB
116 services.cron = {
117 enable = true;
4227853a 118 mailto = "cron@immae.eu";
f807d917
IB
119 systemCronJobs = [
120 ''
fb7611c1
IB
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"
f807d917
IB
125 ''
126 ];
127 };
128
f831eb7e
IB
129 fileSystems."/var/lib/pub/immae/devtools" = {
130 device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/";
131 fsType = "fuse";
132 options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ];
133 };
740a6506 134 environment.systemPackages = [ pkgs.bindfs ];
f831eb7e 135
5dda316b
IB
136 services.zrepl = {
137 enable = true;
138 config = let
139 redis_dump = pkgs.writeScript "redis-dump" ''
140 #! ${pkgs.stdenv.shell}
141 ${pkgs.redis}/bin/redis-cli bgsave
142 '';
143 in ''
144 jobs:
145 - type: push
146 # must not change
147 name: "backup-to-dilion"
148 filesystems:
149 "zpool/root": true
150 "zpool/root/etc": true
151 "zpool/root/var<": true
152 connect:
153 type: ssh+stdinserver
154 host: dilion.immae.eu
155 user: backup
156 port: 22
157 identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"}
158 snapshotting:
159 type: periodic
160 prefix: zrepl_
161 interval: 15m
162 hooks:
163 - type: mysql-lock-tables
164 dsn: "${config.myEnv.zrepl_backup.mysql.user}:${config.myEnv.zrepl_backup.mysql.password}@tcp(localhost)/"
165 filesystems:
166 "zpool/root/var": true
167 - type: command
168 path: ${redis_dump}
169 err_is_fatal: false
170 filesystems:
171 "zpool/root/var": true
172 send:
173 encrypted: true
174 pruning:
175 keep_sender:
176 - type: not_replicated
177 - type: regex
178 regex: "^manual_.*"
179 - type: grid
180 grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d
181 regex: "^zrepl_.*"
182 keep_receiver:
183 - type: regex
184 regex: "^manual_.*"
185 - type: grid
186 grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d
187 regex: "^zrepl_.*"
188 '';
189 };
f807d917
IB
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.
61ebe69b 194 # https://nixos.org/nixos/manual/release-notes.html
d43e0c61 195 system.stateVersion = "20.03"; # Did you read the comment?
f807d917 196}