blob: a97ccd843254342544ff9d40537feecef7cbe82f [file] [log] [blame]
Skyler Greyf08a6192024-06-01 23:55:20 +00001# SPDX-FileCopyrightText: 2024 Auxolotl Infrastructure Contributors
2# SPDX-FileCopyrightText: 2024 Clicks Codes
3#
4# SPDX-License-Identifier: GPL-3.0-only
5
Skyler Grey61f0f852024-06-09 00:02:53 +00006{
7 pkgs,
8 modulesPath,
9 lib,
10 config,
11 ...
12}:
Skyler Greyf08a6192024-06-01 23:55:20 +000013{
Skyler Grey67cf8aa2024-07-28 13:21:32 +000014 age.rekey.hostPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPkKdPSPxsLdx3GUjjyibRLjLl3XfaXmfrrvemDFkjI3";
15
Skyler Greyf08a6192024-06-01 23:55:20 +000016 boot.loader.systemd-boot.enable = true;
17 boot.loader.efi.canTouchEfiVariables = true;
18
19 time.timeZone = "Etc/UTC";
20
21 environment.systemPackages = with pkgs; [ neovim ];
22
23 clicks = {
24 nix.enable = true;
25
Skyler Grey05e11c12024-06-15 00:02:15 +000026 backups.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHYH3yYKcrsDz8U45HF6201BN1nBDQIr4qsGeKh94K6T root@vermilion";
27
Skyler Greyf08a6192024-06-01 23:55:20 +000028 security = {
29 doas.enable = true;
30
31 acme = {
32 enable = true;
Skyler Greyd7e1acd2024-06-22 14:42:11 +000033 defaults = {
34 email = "minion@clicks.codes";
35 dnsProvider = "cloudflare";
Skyler Grey67cf8aa2024-07-28 13:21:32 +000036 environmentFile = config.age.secrets."clicks.security.acme.defaults.environmentFile".path;
Skyler Greyd7e1acd2024-06-22 14:42:11 +000037 };
Skyler Greyf08a6192024-06-01 23:55:20 +000038 };
39 };
40
Skyler Grey3299e4f2024-07-04 00:33:43 +000041 sites."docs.auxolotl.org".enable = true;
42
Skyler Greyf08a6192024-06-01 23:55:20 +000043 services = {
44 ssh.enable = true;
Skyler Grey61f0f852024-06-09 00:02:53 +000045 headscale = {
46 enable = true;
Skyler Greybed35f12024-07-04 00:46:44 +000047 domain = "clicks.domains";
Skyler Grey14375fe2024-06-22 14:43:44 +000048 addr = lib.clicks.constants.hosts.generic;
Skyler Grey61f0f852024-06-09 00:02:53 +000049 oidc = {
50 enable = true;
51 issuer = "https://login.clicks.codes/realms/master";
52 allowed_groups = [ "/clicks" ];
53 client_secret_path =
Skyler Grey67cf8aa2024-07-28 13:21:32 +000054 config.age.secrets."clicks.services.headscale.oidc.client_secret_path".path;
Skyler Grey61f0f852024-06-09 00:02:53 +000055 };
56 database_password_path =
Skyler Grey67cf8aa2024-07-28 13:21:32 +000057 config.age.secrets."clicks.services.headscale.database_password_path".path;
Skyler Grey61f0f852024-06-09 00:02:53 +000058 noise_private_key_path =
Skyler Grey67cf8aa2024-07-28 13:21:32 +000059 config.age.secrets."clicks.services.headscale.noise_private_key_path".path;
Skyler Grey61f0f852024-06-09 00:02:53 +000060 private_key_path =
Skyler Grey67cf8aa2024-07-28 13:21:32 +000061 config.age.secrets."clicks.services.headscale.private_key_path".path;
Skyler Grey0e05b522024-06-11 22:48:00 +000062 acl =
63 let
64 internet = [
65 "0.0.0.0/5"
66 "8.0.0.0/7"
67 "11.0.0.0/8"
68 "12.0.0.0/6"
69 "16.0.0.0/4"
70 "32.0.0.0/3"
71 "64.0.0.0/3"
72 "96.0.0.0/6"
73 "100.0.0.0/10"
74 "100.128.0.0/9"
75 "101.0.0.0/8"
76 "102.0.0.0/7"
77 "104.0.0.0/5"
78 "112.0.0.0/4"
79 "128.0.0.0/3"
80 "160.0.0.0/5"
81 "168.0.0.0/8"
82 "169.0.0.0/9"
83 "169.128.0.0/10"
84 "169.192.0.0/11"
85 "169.224.0.0/12"
86 "169.240.0.0/13"
87 "169.248.0.0/14"
88 "169.252.0.0/15"
89 "169.255.0.0/16"
90 "170.0.0.0/7"
91 "172.0.0.0/12"
92 "172.32.0.0/11"
93 "172.64.0.0/10"
94 "172.128.0.0/9"
95 "173.0.0.0/8"
96 "174.0.0.0/7"
97 "176.0.0.0/4"
98 "192.0.0.0/9"
99 "192.128.0.0/11"
100 "192.160.0.0/13"
101 "192.169.0.0/16"
102 "192.170.0.0/15"
103 "192.172.0.0/14"
104 "192.176.0.0/12"
105 "192.192.0.0/10"
106 "193.0.0.0/8"
107 "194.0.0.0/7"
108 "196.0.0.0/6"
109 "200.0.0.0/5"
110 "208.0.0.0/4"
111 "224.0.0.0/3"
112 "ipv6-internet"
113 # A nasty hack used because ipv6 colons were messing with dst
114 # ports
115 ]; # Should be replaceable with autogroup:internet in next release
116 in
117 {
118 groups."group:users" = [
Skyler Grey0e05b522024-06-11 22:48:00 +0000119 "coded"
Skyler Greyefc62522024-06-15 00:23:06 +0000120 "maddie"
121 "minion"
Skyler Grey0e05b522024-06-11 22:48:00 +0000122 "pineafan"
Skyler Greyefc62522024-06-15 00:23:06 +0000123 "zanderp25"
Skyler Grey0e05b522024-06-11 22:48:00 +0000124 ];
Skyler Grey985a6122024-07-17 22:00:16 +0000125 groups."group:friends" = [
126 "sirdigalot"
127 ];
Skyler Grey0e05b522024-06-11 22:48:00 +0000128 groups."group:areas" = [
129 # Some phonetic alphabet names are excluded here to avoid confusing
130 # them with given names
131 "alpha"
132 "bravo"
Skyler Grey0e05b522024-06-11 22:48:00 +0000133 "echo"
134 "foxtrot"
Skyler Grey0e05b522024-06-11 22:48:00 +0000135 "hotel"
136 "india"
137 "kilo"
138 "lima"
139 "november"
140 "papa"
Skyler Grey0e05b522024-06-11 22:48:00 +0000141 "sierra"
142 "tango"
143 "uniform"
144 "whiskey"
145 "xray"
146 "yankee"
147 "zulu"
148 ];
149 hosts.ipv6-internet = "2000::/3";
Skyler Grey2154d222024-06-10 17:17:51 +0000150
Skyler Grey0e05b522024-06-11 22:48:00 +0000151 acls = [
152 {
153 action = "accept";
154 src = [ "group:users" ];
155 dst = [
156 "group:users:*"
Skyler Grey985a6122024-07-17 22:00:16 +0000157 "group:friends:*"
Skyler Grey0e05b522024-06-11 22:48:00 +0000158 "group:areas:*"
159 ] ++ (lib.forEach internet (host: "${host}:*"));
160 }
161 {
162 action = "accept";
Skyler Grey985a6122024-07-17 22:00:16 +0000163 src = [ "group:friends" ];
164 dst = [
165 "group:users:*"
166 "group:friends:*"
167 ];
168 }
169 {
170 action = "accept";
Skyler Grey0e05b522024-06-11 22:48:00 +0000171 src = [ "group:areas" ];
172 dst = [ "group:areas:*" ];
173 }
174 ];
175 };
Skyler Grey61f0f852024-06-09 00:02:53 +0000176 };
Skyler Grey0a0912a2024-07-04 00:13:40 +0000177 fava = {
178 enable = true;
179 tailscaleAuth = true;
180 accounts = {
Skyler Grey5e8bba22024-07-12 14:31:49 +0000181 "clicks" = lib.home-manager.hm.dag.entryAnywhere {
182 name = "Clicks Codes";
183 beancountExtraOptions.operating_currency = "GBP";
184 };
185 "coded" = lib.home-manager.hm.dag.entryBetween [ "testing" ] [ "clicks" ] {
186 name = "Samuel Shuert";
187 beancountExtraOptions.operating_currency = "USD";
188 };
189 "minion" = lib.home-manager.hm.dag.entryBetween [ "testing" ] [ "clicks" ] {
190 name = "Skyler Grey";
191 beancountExtraOptions.operating_currency = "GBP";
192 };
193 "testing" = lib.home-manager.hm.dag.entryAfter [ "clicks" ] {
194 name = "Test Data - May Be Wiped At Any Time";
195 };
Skyler Grey0a0912a2024-07-04 00:13:40 +0000196 };
197 domain = "fava.clicks.codes";
198 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000199 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000200
Skyler Grey8ef34812024-06-09 19:42:15 +0000201 networking.tailscale = {
202 enable = true;
203 authKeyFile =
Skyler Grey67cf8aa2024-07-28 13:21:32 +0000204 config.age.secrets."clicks.networking.tailscale.authKeyFile".path;
Skyler Grey8ef34812024-06-09 19:42:15 +0000205 };
206
Skyler Grey40ae7a02024-06-06 21:22:25 +0000207 storage = {
Skyler Greyf4d05f02024-06-06 21:25:39 +0000208 raid.enable = true;
Skyler Grey40ae7a02024-06-06 21:22:25 +0000209 impermanence = {
210 enable = true;
Skyler Greyd3377402024-06-06 22:01:26 +0000211 devices = {
212 root = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
213 persist = "/dev/md/a1d1:persist";
214 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000215 };
216 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000217 };
218
219 boot.initrd.availableKernelModules = [
220 "nvme"
221 "xhci_pci"
222 "ahci"
223 "usbhid"
224 "uas"
225 "usb_storage"
226 "sd_mod"
227 ];
228 boot.initrd.kernelModules = [ ];
229 boot.kernelModules = [ "kvm-amd" ];
230 boot.extraModulePackages = [ ];
231
Skyler Grey40ae7a02024-06-06 21:22:25 +0000232 fileSystems."/nix" = {
Skyler Greyf08a6192024-06-01 23:55:20 +0000233 device = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
234 fsType = "btrfs";
Skyler Grey40ae7a02024-06-06 21:22:25 +0000235 options = [ "subvol=@nix" ];
Skyler Greyf08a6192024-06-01 23:55:20 +0000236 };
237
238 fileSystems."/boot" = {
239 device = "/dev/disk/by-uuid/880D-BBAB";
240 fsType = "vfat";
241 options = [
242 "fmask=0022"
243 "dmask=0022"
244 ];
245 };
246
247 swapDevices = [ ];
248
249 networking.useDHCP = true;
250
251 system.stateVersion = "24.05";
Skyler Grey61f0f852024-06-09 00:02:53 +0000252
Skyler Grey67cf8aa2024-07-28 13:21:32 +0000253 age.secrets."clicks.security.acme.defaults.environmentFile".rekeyFile = ./clicks.security.acme.defaults.environmentFile.age;
254
255 age.secrets."clicks.services.headscale.oidc.client_secret_path" = {
256 rekeyFile = ./clicks.services.headscale.oidc.client_secret_path.age;
Skyler Grey61f0f852024-06-09 00:02:53 +0000257 group = "headscale";
Skyler Grey67cf8aa2024-07-28 13:21:32 +0000258 mode = "440";
259 };
260 age.secrets."clicks.services.headscale.database_password_path" = {
261 rekeyFile = ./clicks.services.headscale.database_password_path.age;
262 group = "headscale";
263 mode = "440";
264 };
265 age.secrets."clicks.services.headscale.noise_private_key_path" = {
266 rekeyFile = ./clicks.services.headscale.noise_private_key_path.age;
267 group = "headscale";
268 mode = "440";
269 };
270 age.secrets."clicks.services.headscale.private_key_path" = {
271 rekeyFile = ./clicks.services.headscale.private_key_path.age;
272 group = "headscale";
273 mode = "440";
Skyler Grey61f0f852024-06-09 00:02:53 +0000274 };
Skyler Grey8ef34812024-06-09 19:42:15 +0000275
Skyler Grey67cf8aa2024-07-28 13:21:32 +0000276 age.secrets."clicks.networking.tailscale.authKeyFile".rekeyFile = ./clicks.networking.tailscale.authKeyFile.age;
Skyler Greyf08a6192024-06-01 23:55:20 +0000277}