]>
Commit | Line | Data |
---|---|---|
f807d917 | 1 | { privateFiles }: |
7e214bf9 | 2 | { config, pkgs, lib, ... }: |
f807d917 | 3 | { |
31e11cdf | 4 | boot.supportedFilesystems = [ "zfs" ]; |
7e214bf9 | 5 | boot.kernelParams = ["zfs.zfs_arc_max=6442450944"]; |
f807d917 | 6 | boot.kernelPackages = pkgs.linuxPackages_latest; |
ab8f306d | 7 | myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; |
f807d917 | 8 | |
7e214bf9 IB |
9 | fileSystems = { |
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"; }; | |
16 | }; | |
17 | boot.initrd.secrets = { | |
18 | "/boot/pass.key" = "/boot/pass.key"; | |
19 | }; | |
20 | ||
21 | services.zfs = { | |
7e214bf9 IB |
22 | autoScrub = { |
23 | enable = true; | |
24 | }; | |
25 | }; | |
f807d917 | 26 | networking = { |
31e11cdf | 27 | hostId = "8262ca33"; # generated with head -c4 /dev/urandom | od -A none -t x4 |
f807d917 IB |
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; }) | |
619e4f46 | 32 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips); |
f807d917 IB |
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 [])) | |
619e4f46 | 35 | config.hostEnv.ips); |
f807d917 IB |
36 | }; |
37 | ||
38 | imports = builtins.attrValues (import ../..); | |
39 | ||
63cd475c IB |
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; | |
43 | }; | |
f807d917 IB |
44 | myServices.buildbot.enable = true; |
45 | myServices.databases.enable = true; | |
46 | myServices.gitolite.enable = true; | |
3bc32d9e | 47 | myServices.monitoring.enable = true; |
f807d917 IB |
48 | myServices.irc.enable = true; |
49 | myServices.pub.enable = true; | |
50 | myServices.tasks.enable = true; | |
8415083e IB |
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; | |
3f453c7d | 56 | myServices.ejabberd.enable = true; |
ea9c6fe8 | 57 | myServices.vpn.enable = true; |
f807d917 | 58 | services.pure-ftpd.enable = true; |
d2e703c5 | 59 | services.duplyBackup.enable = true; |
213c323a | 60 | services.duplyBackup.profiles.oldies.rootDir = "/var/lib/oldies"; |
f807d917 | 61 | |
8bf83d7a IB |
62 | secrets.keys = [ |
63 | { | |
5dda316b | 64 | dest = "zrepl_backup/identity"; |
8bf83d7a IB |
65 | user = "root"; |
66 | group = "root"; | |
67 | permissions = "0400"; | |
5dda316b | 68 | text = config.myEnv.zrepl_backup.ssh_key.private; |
8bf83d7a IB |
69 | } |
70 | ]; | |
71 | programs.ssh.knownHosts.dilion = { | |
72 | hostNames = ["dilion.immae.eu"]; | |
73 | publicKey = let | |
74 | profile = config.myEnv.rsync_backup.profiles.dilion; | |
75 | in | |
76 | "${profile.host_key_type} ${profile.host_key}"; | |
77 | }; | |
78 | ||
f807d917 IB |
79 | deployment = { |
80 | targetEnv = "hetzner"; | |
81 | hetzner = { | |
ab8f306d IB |
82 | robotUser = config.myEnv.hetzner.user; |
83 | robotPass = config.myEnv.hetzner.pass; | |
619e4f46 | 84 | mainIPv4 = config.hostEnv.ips.main.ip4; |
f807d917 IB |
85 | partitions = '' |
86 | clearpart --all --initlabel --drives=sda,sdb | |
87 | ||
88 | part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda | |
89 | part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb | |
90 | ||
91 | part raid.1 --grow --ondisk=sda | |
92 | part raid.2 --grow --ondisk=sdb | |
93 | ||
94 | raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 | |
95 | ''; | |
96 | }; | |
97 | }; | |
98 | ||
99 | services.cron = { | |
100 | enable = true; | |
4227853a | 101 | mailto = "cron@immae.eu"; |
f807d917 IB |
102 | systemCronJobs = [ |
103 | '' | |
fb7611c1 IB |
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" | |
f807d917 IB |
108 | '' |
109 | ]; | |
110 | }; | |
111 | ||
f831eb7e IB |
112 | fileSystems."/var/lib/pub/immae/devtools" = { |
113 | device = "/run/current-system/sw/bin/bindfs#/var/lib/ftp/devtools.immae.eu/"; | |
114 | fsType = "fuse"; | |
115 | options = [ "force-user=pub" "create-for-user=wwwrun" "create-for-group=wwwrun" ]; | |
116 | }; | |
740a6506 | 117 | environment.systemPackages = [ pkgs.bindfs ]; |
f831eb7e | 118 | |
5dda316b IB |
119 | services.zrepl = { |
120 | enable = true; | |
121 | config = let | |
122 | redis_dump = pkgs.writeScript "redis-dump" '' | |
123 | #! ${pkgs.stdenv.shell} | |
124 | ${pkgs.redis}/bin/redis-cli bgsave | |
125 | ''; | |
126 | in '' | |
127 | jobs: | |
128 | - type: push | |
129 | # must not change | |
130 | name: "backup-to-dilion" | |
131 | filesystems: | |
132 | "zpool/root": true | |
133 | "zpool/root/etc": true | |
134 | "zpool/root/var<": true | |
135 | connect: | |
136 | type: ssh+stdinserver | |
137 | host: dilion.immae.eu | |
138 | user: backup | |
139 | port: 22 | |
140 | identity_file: ${config.secrets.fullPaths."zrepl_backup/identity"} | |
141 | snapshotting: | |
142 | type: periodic | |
143 | prefix: zrepl_ | |
144 | interval: 15m | |
145 | hooks: | |
146 | - type: mysql-lock-tables | |
147 | dsn: "${config.myEnv.zrepl_backup.mysql.user}:${config.myEnv.zrepl_backup.mysql.password}@tcp(localhost)/" | |
148 | filesystems: | |
149 | "zpool/root/var": true | |
150 | - type: command | |
151 | path: ${redis_dump} | |
152 | err_is_fatal: false | |
153 | filesystems: | |
154 | "zpool/root/var": true | |
155 | send: | |
156 | encrypted: true | |
157 | pruning: | |
158 | keep_sender: | |
159 | - type: not_replicated | |
160 | - type: regex | |
161 | regex: "^manual_.*" | |
162 | - type: grid | |
163 | grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d | |
164 | regex: "^zrepl_.*" | |
165 | keep_receiver: | |
166 | - type: regex | |
167 | regex: "^manual_.*" | |
168 | - type: grid | |
169 | grid: 1x1h(keep=all) | 24x1h | 7x1d | 4x7d | 6x30d | |
170 | regex: "^zrepl_.*" | |
171 | ''; | |
172 | }; | |
f807d917 IB |
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. | |
61ebe69b | 177 | # https://nixos.org/nixos/manual/release-notes.html |
d43e0c61 | 178 | system.stateVersion = "20.03"; # Did you read the comment? |
f807d917 | 179 | } |