Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2024 Auxolotl Infrastructure Contributors |
| 2 | # SPDX-FileCopyrightText: 2024 Clicks Codes |
| 3 | # |
| 4 | # SPDX-License-Identifier: GPL-3.0-only |
| 5 | |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 6 | { |
| 7 | pkgs, |
| 8 | modulesPath, |
| 9 | lib, |
| 10 | config, |
| 11 | ... |
| 12 | }: |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 13 | { |
| 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 Grey | 05e11c1 | 2024-06-15 00:02:15 +0000 | [diff] [blame] | 24 | backups.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHYH3yYKcrsDz8U45HF6201BN1nBDQIr4qsGeKh94K6T root@vermilion"; |
| 25 | |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 26 | security = { |
| 27 | doas.enable = true; |
| 28 | |
| 29 | acme = { |
| 30 | enable = true; |
Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 31 | 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 Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 36 | }; |
| 37 | }; |
| 38 | |
| 39 | services = { |
| 40 | ssh.enable = true; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 41 | headscale = { |
| 42 | enable = true; |
Skyler Grey | bed35f1 | 2024-07-04 00:46:44 +0000 | [diff] [blame] | 43 | domain = "clicks.domains"; |
Skyler Grey | 14375fe | 2024-06-22 14:43:44 +0000 | [diff] [blame^] | 44 | addr = lib.clicks.constants.hosts.generic; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 45 | 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 Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 58 | 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 Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 115 | "coded" |
Skyler Grey | efc6252 | 2024-06-15 00:23:06 +0000 | [diff] [blame] | 116 | "maddie" |
| 117 | "minion" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 118 | "pineafan" |
Skyler Grey | efc6252 | 2024-06-15 00:23:06 +0000 | [diff] [blame] | 119 | "zanderp25" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 120 | ]; |
| 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 Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 126 | "echo" |
| 127 | "foxtrot" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 128 | "hotel" |
| 129 | "india" |
| 130 | "kilo" |
| 131 | "lima" |
| 132 | "november" |
| 133 | "papa" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 134 | "sierra" |
| 135 | "tango" |
| 136 | "uniform" |
| 137 | "whiskey" |
| 138 | "xray" |
| 139 | "yankee" |
| 140 | "zulu" |
| 141 | ]; |
| 142 | hosts.ipv6-internet = "2000::/3"; |
Skyler Grey | 2154d22 | 2024-06-10 17:17:51 +0000 | [diff] [blame] | 143 | |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 144 | 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 Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 160 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 161 | }; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 162 | |
Skyler Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 163 | networking.tailscale = { |
| 164 | enable = true; |
| 165 | authKeyFile = |
| 166 | config.clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}".paths.authKey; |
| 167 | }; |
| 168 | |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 169 | storage = { |
Skyler Grey | f4d05f0 | 2024-06-06 21:25:39 +0000 | [diff] [blame] | 170 | raid.enable = true; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 171 | impermanence = { |
| 172 | enable = true; |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 173 | devices = { |
| 174 | root = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c"; |
| 175 | persist = "/dev/md/a1d1:persist"; |
| 176 | }; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 177 | }; |
| 178 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 179 | }; |
| 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 Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 194 | fileSystems."/nix" = { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 195 | device = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c"; |
| 196 | fsType = "btrfs"; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 197 | options = [ "subvol=@nix" ]; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 198 | }; |
| 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 Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 214 | |
| 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 Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 226 | |
| 227 | clicks.secrets."${lib.clicks.secrets.name ./tailscale.sops.json}" = { |
| 228 | file = ./tailscale.sops.json; |
| 229 | keys = [ "authKey" ]; |
| 230 | }; |
Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 231 | |
| 232 | clicks.secrets."${lib.clicks.secrets.name ./acme.sops.env.bin}".file = ./acme.sops.env.bin; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 233 | } |