blob: ee2de5031d486d0eb77e9ad9da7721dd58ba8a72 [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 Greyf08a6192024-06-01 23:55:20 +0000163 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000164
Skyler Grey8ef34812024-06-09 19:42:15 +0000165 networking.tailscale = {
166 enable = true;
167 authKeyFile =
168 config.clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}".paths.authKey;
169 };
170
Skyler Grey40ae7a02024-06-06 21:22:25 +0000171 storage = {
Skyler Greyf4d05f02024-06-06 21:25:39 +0000172 raid.enable = true;
Skyler Grey40ae7a02024-06-06 21:22:25 +0000173 impermanence = {
174 enable = true;
Skyler Greyd3377402024-06-06 22:01:26 +0000175 devices = {
176 root = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
177 persist = "/dev/md/a1d1:persist";
178 };
Skyler Grey40ae7a02024-06-06 21:22:25 +0000179 };
180 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000181 };
182
183 boot.initrd.availableKernelModules = [
184 "nvme"
185 "xhci_pci"
186 "ahci"
187 "usbhid"
188 "uas"
189 "usb_storage"
190 "sd_mod"
191 ];
192 boot.initrd.kernelModules = [ ];
193 boot.kernelModules = [ "kvm-amd" ];
194 boot.extraModulePackages = [ ];
195
Skyler Grey40ae7a02024-06-06 21:22:25 +0000196 fileSystems."/nix" = {
Skyler Greyf08a6192024-06-01 23:55:20 +0000197 device = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c";
198 fsType = "btrfs";
Skyler Grey40ae7a02024-06-06 21:22:25 +0000199 options = [ "subvol=@nix" ];
Skyler Greyf08a6192024-06-01 23:55:20 +0000200 };
201
202 fileSystems."/boot" = {
203 device = "/dev/disk/by-uuid/880D-BBAB";
204 fsType = "vfat";
205 options = [
206 "fmask=0022"
207 "dmask=0022"
208 ];
209 };
210
211 swapDevices = [ ];
212
213 networking.useDHCP = true;
214
215 system.stateVersion = "24.05";
Skyler Grey61f0f852024-06-09 00:02:53 +0000216
217 clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}" = {
218 file = ./headscale.sops.json;
219 group = "headscale";
220 keys = [
221 "oidc_client_secret"
222 "database_password"
223 "noise_private_key"
224 "private_key"
225 ];
226 neededForUsers = false;
227 };
Skyler Grey8ef34812024-06-09 19:42:15 +0000228
229 clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}" = {
230 file = ./tailscale.sops.json;
231 keys = [ "authKey" ];
232 };
Skyler Greyd7e1acd2024-06-22 14:42:11 +0000233
234 clicks.secrets."${lib.clicks.secrets.name ./acme.sops.env.bin}".file = ./acme.sops.env.bin;
Skyler Greyf08a6192024-06-01 23:55:20 +0000235}