blob: 52686a85788655b2cebdb7a5bcb097ff6178daae [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
39 services = {
40 ssh.enable = true;
Skyler Grey61f0f852024-06-09 00:02:53 +000041 headscale = {
42 enable = true;
Skyler Greybed35f12024-07-04 00:46:44 +000043 domain = "clicks.domains";
Skyler Grey14375fe2024-06-22 14:43:44 +000044 addr = lib.clicks.constants.hosts.generic;
Skyler Grey61f0f852024-06-09 00:02:53 +000045 oidc = {
46 enable = true;
47 issuer = "https://login.clicks.codes/realms/master";
48 allowed_groups = [ "/clicks" ];
49 client_secret_path =
50 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.oidc_client_secret;
51 };
52 database_password_path =
53 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.database_password;
54 noise_private_key_path =
55 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.noise_private_key;
56 private_key_path =
57 config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.private_key;
Skyler Grey0e05b522024-06-11 22:48:00 +000058 acl =
59 let
60 internet = [
61 "0.0.0.0/5"
62 "8.0.0.0/7"
63 "11.0.0.0/8"
64 "12.0.0.0/6"
65 "16.0.0.0/4"
66 "32.0.0.0/3"
67 "64.0.0.0/3"
68 "96.0.0.0/6"
69 "100.0.0.0/10"
70 "100.128.0.0/9"
71 "101.0.0.0/8"
72 "102.0.0.0/7"
73 "104.0.0.0/5"
74 "112.0.0.0/4"
75 "128.0.0.0/3"
76 "160.0.0.0/5"
77 "168.0.0.0/8"
78 "169.0.0.0/9"
79 "169.128.0.0/10"
80 "169.192.0.0/11"
81 "169.224.0.0/12"
82 "169.240.0.0/13"
83 "169.248.0.0/14"
84 "169.252.0.0/15"
85 "169.255.0.0/16"
86 "170.0.0.0/7"
87 "172.0.0.0/12"
88 "172.32.0.0/11"
89 "172.64.0.0/10"
90 "172.128.0.0/9"
91 "173.0.0.0/8"
92 "174.0.0.0/7"
93 "176.0.0.0/4"
94 "192.0.0.0/9"
95 "192.128.0.0/11"
96 "192.160.0.0/13"
97 "192.169.0.0/16"
98 "192.170.0.0/15"
99 "192.172.0.0/14"
100 "192.176.0.0/12"
101 "192.192.0.0/10"
102 "193.0.0.0/8"
103 "194.0.0.0/7"
104 "196.0.0.0/6"
105 "200.0.0.0/5"
106 "208.0.0.0/4"
107 "224.0.0.0/3"
108 "ipv6-internet"
109 # A nasty hack used because ipv6 colons were messing with dst
110 # ports
111 ]; # Should be replaceable with autogroup:internet in next release
112 in
113 {
114 groups."group:users" = [
Skyler Grey0e05b522024-06-11 22:48:00 +0000115 "coded"
Skyler Greyefc62522024-06-15 00:23:06 +0000116 "maddie"
117 "minion"
Skyler Grey0e05b522024-06-11 22:48:00 +0000118 "pineafan"
Skyler Greyefc62522024-06-15 00:23:06 +0000119 "zanderp25"
Skyler Grey0e05b522024-06-11 22:48:00 +0000120 ];
121 groups."group:areas" = [
122 # Some phonetic alphabet names are excluded here to avoid confusing
123 # them with given names
124 "alpha"
125 "bravo"
Skyler Grey0e05b522024-06-11 22:48:00 +0000126 "echo"
127 "foxtrot"
Skyler Grey0e05b522024-06-11 22:48:00 +0000128 "hotel"
129 "india"
130 "kilo"
131 "lima"
132 "november"
133 "papa"
Skyler Grey0e05b522024-06-11 22:48:00 +0000134 "sierra"
135 "tango"
136 "uniform"
137 "whiskey"
138 "xray"
139 "yankee"
140 "zulu"
141 ];
142 hosts.ipv6-internet = "2000::/3";
Skyler Grey2154d222024-06-10 17:17:51 +0000143
Skyler Grey0e05b522024-06-11 22:48:00 +0000144 acls = [
145 {
146 action = "accept";
147 src = [ "group:users" ];
148 dst = [
149 "group:users:*"
150 "group:areas:*"
151 ] ++ (lib.forEach internet (host: "${host}:*"));
152 }
153 {
154 action = "accept";
155 src = [ "group:areas" ];
156 dst = [ "group:areas:*" ];
157 }
158 ];
159 };
Skyler Grey61f0f852024-06-09 00:02:53 +0000160 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000161 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000162
Skyler Grey8ef34812024-06-09 19:42:15 +0000163 networking.tailscale = {
164 enable = true;
165 authKeyFile =
166 config.clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}".paths.authKey;
167 };
168
Skyler Grey40ae7a02024-06-06 21:22:25 +0000169 storage = {
Skyler Greyf4d05f02024-06-06 21:25:39 +0000170 raid.enable = true;
Skyler Grey40ae7a02024-06-06 21:22:25 +0000171 impermanence = {
172 enable = true;
Skyler Greyd3377402024-06-06 22:01:26 +0000173 devices = {
174 root = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
175 persist = "/dev/md/a1d1:persist";
176 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000177 };
178 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000179 };
180
181 boot.initrd.availableKernelModules = [
182 "nvme"
183 "xhci_pci"
184 "ahci"
185 "usbhid"
186 "uas"
187 "usb_storage"
188 "sd_mod"
189 ];
190 boot.initrd.kernelModules = [ ];
191 boot.kernelModules = [ "kvm-amd" ];
192 boot.extraModulePackages = [ ];
193
Skyler Grey40ae7a02024-06-06 21:22:25 +0000194 fileSystems."/nix" = {
Skyler Greyf08a6192024-06-01 23:55:20 +0000195 device = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
196 fsType = "btrfs";
Skyler Grey40ae7a02024-06-06 21:22:25 +0000197 options = [ "subvol=@nix" ];
Skyler Greyf08a6192024-06-01 23:55:20 +0000198 };
199
200 fileSystems."/boot" = {
201 device = "/dev/disk/by-uuid/880D-BBAB";
202 fsType = "vfat";
203 options = [
204 "fmask=0022"
205 "dmask=0022"
206 ];
207 };
208
209 swapDevices = [ ];
210
211 networking.useDHCP = true;
212
213 system.stateVersion = "24.05";
Skyler Grey61f0f852024-06-09 00:02:53 +0000214
215 clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}" = {
216 file = ./headscale.sops.json;
217 group = "headscale";
218 keys = [
219 "oidc_client_secret"
220 "database_password"
221 "noise_private_key"
222 "private_key"
223 ];
224 neededForUsers = false;
225 };
Skyler Grey8ef34812024-06-09 19:42:15 +0000226
227 clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}" = {
228 file = ./tailscale.sops.json;
229 keys = [ "authKey" ];
230 };
Skyler Greyd7e1acd2024-06-22 14:42:11 +0000231
232 clicks.secrets."${lib.clicks.secrets.name ./acme.sops.env.bin}".file = ./acme.sops.env.bin;
Skyler Greyf08a6192024-06-01 23:55:20 +0000233}