blob: 2a9b99bf9399771b8d26ad5e60daac146c3a5767 [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{
14 boot.loader.systemd-boot.enable = true;
15 boot.loader.efi.canTouchEfiVariables = true;
16
17 time.timeZone = "Etc/UTC";
18
19 environment.systemPackages = with pkgs; [ neovim ];
20
21 clicks = {
22 nix.enable = true;
23
Skyler Grey05e11c12024-06-15 00:02:15 +000024 backups.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHYH3yYKcrsDz8U45HF6201BN1nBDQIr4qsGeKh94K6T root@vermilion";
25
Skyler Greyf08a6192024-06-01 23:55:20 +000026 security = {
27 doas.enable = true;
28
29 acme = {
30 enable = true;
Skyler Greyd7e1acd2024-06-22 14:42:11 +000031 defaults = {
32 email = "minion@clicks.codes";
33 dnsProvider = "cloudflare";
34 environmentFile = config.clicks.secrets."${lib.clicks.secrets.name ./acme.sops.env.bin}".path;
35 };
Skyler Greyf08a6192024-06-01 23:55:20 +000036 };
37 };
38
Skyler Grey3299e4f2024-07-04 00:33:43 +000039 sites."docs.auxolotl.org".enable = true;
40
Skyler Greyf08a6192024-06-01 23:55:20 +000041 services = {
42 ssh.enable = true;
Skyler Grey61f0f852024-06-09 00:02:53 +000043 headscale = {
44 enable = true;
Skyler Greybed35f12024-07-04 00:46:44 +000045 domain = "clicks.domains";
Skyler Grey14375fe2024-06-22 14:43:44 +000046 addr = lib.clicks.constants.hosts.generic;
Skyler Grey61f0f852024-06-09 00:02:53 +000047 oidc = {
48 enable = true;
49 issuer = "https://login.clicks.codes/realms/master";
50 allowed_groups = [ "/clicks" ];
51 client_secret_path =
52 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.oidc_client_secret;
53 };
54 database_password_path =
55 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.database_password;
56 noise_private_key_path =
57 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.noise_private_key;
58 private_key_path =
59 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.private_key;
Skyler Grey0e05b522024-06-11 22:48:00 +000060 acl =
61 let
62 internet = [
63 "0.0.0.0/5"
64 "8.0.0.0/7"
65 "11.0.0.0/8"
66 "12.0.0.0/6"
67 "16.0.0.0/4"
68 "32.0.0.0/3"
69 "64.0.0.0/3"
70 "96.0.0.0/6"
71 "100.0.0.0/10"
72 "100.128.0.0/9"
73 "101.0.0.0/8"
74 "102.0.0.0/7"
75 "104.0.0.0/5"
76 "112.0.0.0/4"
77 "128.0.0.0/3"
78 "160.0.0.0/5"
79 "168.0.0.0/8"
80 "169.0.0.0/9"
81 "169.128.0.0/10"
82 "169.192.0.0/11"
83 "169.224.0.0/12"
84 "169.240.0.0/13"
85 "169.248.0.0/14"
86 "169.252.0.0/15"
87 "169.255.0.0/16"
88 "170.0.0.0/7"
89 "172.0.0.0/12"
90 "172.32.0.0/11"
91 "172.64.0.0/10"
92 "172.128.0.0/9"
93 "173.0.0.0/8"
94 "174.0.0.0/7"
95 "176.0.0.0/4"
96 "192.0.0.0/9"
97 "192.128.0.0/11"
98 "192.160.0.0/13"
99 "192.169.0.0/16"
100 "192.170.0.0/15"
101 "192.172.0.0/14"
102 "192.176.0.0/12"
103 "192.192.0.0/10"
104 "193.0.0.0/8"
105 "194.0.0.0/7"
106 "196.0.0.0/6"
107 "200.0.0.0/5"
108 "208.0.0.0/4"
109 "224.0.0.0/3"
110 "ipv6-internet"
111 # A nasty hack used because ipv6 colons were messing with dst
112 # ports
113 ]; # Should be replaceable with autogroup:internet in next release
114 in
115 {
116 groups."group:users" = [
Skyler Grey0e05b522024-06-11 22:48:00 +0000117 "coded"
Skyler Greyefc62522024-06-15 00:23:06 +0000118 "maddie"
119 "minion"
Skyler Grey0e05b522024-06-11 22:48:00 +0000120 "pineafan"
Skyler Greyefc62522024-06-15 00:23:06 +0000121 "zanderp25"
Skyler Grey0e05b522024-06-11 22:48:00 +0000122 ];
123 groups."group:areas" = [
124 # Some phonetic alphabet names are excluded here to avoid confusing
125 # them with given names
126 "alpha"
127 "bravo"
Skyler Grey0e05b522024-06-11 22:48:00 +0000128 "echo"
129 "foxtrot"
Skyler Grey0e05b522024-06-11 22:48:00 +0000130 "hotel"
131 "india"
132 "kilo"
133 "lima"
134 "november"
135 "papa"
Skyler Grey0e05b522024-06-11 22:48:00 +0000136 "sierra"
137 "tango"
138 "uniform"
139 "whiskey"
140 "xray"
141 "yankee"
142 "zulu"
143 ];
144 hosts.ipv6-internet = "2000::/3";
Skyler Grey2154d222024-06-10 17:17:51 +0000145
Skyler Grey0e05b522024-06-11 22:48:00 +0000146 acls = [
147 {
148 action = "accept";
149 src = [ "group:users" ];
150 dst = [
151 "group:users:*"
152 "group:areas:*"
153 ] ++ (lib.forEach internet (host: "${host}:*"));
154 }
155 {
156 action = "accept";
157 src = [ "group:areas" ];
158 dst = [ "group:areas:*" ];
159 }
160 ];
161 };
Skyler Grey61f0f852024-06-09 00:02:53 +0000162 };
Skyler Grey0a0912a2024-07-04 00:13:40 +0000163 fava = {
164 enable = true;
165 tailscaleAuth = true;
166 accounts = {
167 "clicks" = lib.home-manager.hm.dag.entryAnywhere "Clicks Codes";
168 "coded" = lib.home-manager.hm.dag.entryBetween [ "testing" ] [ "clicks" ] "Samuel Shuert";
169 "minion" = lib.home-manager.hm.dag.entryBetween [ "testing" ] [ "clicks" ] "Skyler Grey";
170 "testing" = lib.home-manager.hm.dag.entryAfter [ "clicks" ] "Test Data - May Be Wiped At Any Time";
171 };
172 domain = "fava.clicks.codes";
173 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000174 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000175
Skyler Grey8ef34812024-06-09 19:42:15 +0000176 networking.tailscale = {
177 enable = true;
178 authKeyFile =
179 config.clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}".paths.authKey;
180 };
181
Skyler Grey40ae7a02024-06-06 21:22:25 +0000182 storage = {
Skyler Greyf4d05f02024-06-06 21:25:39 +0000183 raid.enable = true;
Skyler Grey40ae7a02024-06-06 21:22:25 +0000184 impermanence = {
185 enable = true;
Skyler Greyd3377402024-06-06 22:01:26 +0000186 devices = {
187 root = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
188 persist = "/dev/md/a1d1:persist";
189 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000190 };
191 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000192 };
193
194 boot.initrd.availableKernelModules = [
195 "nvme"
196 "xhci_pci"
197 "ahci"
198 "usbhid"
199 "uas"
200 "usb_storage"
201 "sd_mod"
202 ];
203 boot.initrd.kernelModules = [ ];
204 boot.kernelModules = [ "kvm-amd" ];
205 boot.extraModulePackages = [ ];
206
Skyler Grey40ae7a02024-06-06 21:22:25 +0000207 fileSystems."/nix" = {
Skyler Greyf08a6192024-06-01 23:55:20 +0000208 device = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
209 fsType = "btrfs";
Skyler Grey40ae7a02024-06-06 21:22:25 +0000210 options = [ "subvol=@nix" ];
Skyler Greyf08a6192024-06-01 23:55:20 +0000211 };
212
213 fileSystems."/boot" = {
214 device = "/dev/disk/by-uuid/880D-BBAB";
215 fsType = "vfat";
216 options = [
217 "fmask=0022"
218 "dmask=0022"
219 ];
220 };
221
222 swapDevices = [ ];
223
224 networking.useDHCP = true;
225
226 system.stateVersion = "24.05";
Skyler Grey61f0f852024-06-09 00:02:53 +0000227
228 clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}" = {
229 file = ./headscale.sops.json;
230 group = "headscale";
231 keys = [
232 "oidc_client_secret"
233 "database_password"
234 "noise_private_key"
235 "private_key"
236 ];
237 neededForUsers = false;
238 };
Skyler Grey8ef34812024-06-09 19:42:15 +0000239
240 clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}" = {
241 file = ./tailscale.sops.json;
242 keys = [ "authKey" ];
243 };
Skyler Greyd7e1acd2024-06-22 14:42:11 +0000244
245 clicks.secrets."${lib.clicks.secrets.name ./acme.sops.env.bin}".file = ./acme.sops.env.bin;
Skyler Greyf08a6192024-06-01 23:55:20 +0000246}