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 | { |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 14 | age.rekey.hostPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPkKdPSPxsLdx3GUjjyibRLjLl3XfaXmfrrvemDFkjI3"; |
| 15 | |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 16 | 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 Grey | 05e11c1 | 2024-06-15 00:02:15 +0000 | [diff] [blame] | 26 | backups.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHYH3yYKcrsDz8U45HF6201BN1nBDQIr4qsGeKh94K6T root@vermilion"; |
| 27 | |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 28 | security = { |
| 29 | doas.enable = true; |
| 30 | |
| 31 | acme = { |
| 32 | enable = true; |
Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 33 | defaults = { |
| 34 | email = "minion@clicks.codes"; |
| 35 | dnsProvider = "cloudflare"; |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 36 | environmentFile = config.age.secrets."clicks.security.acme.defaults.environmentFile".path; |
Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 37 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 38 | }; |
| 39 | }; |
| 40 | |
Skyler Grey | 3299e4f | 2024-07-04 00:33:43 +0000 | [diff] [blame] | 41 | sites."docs.auxolotl.org".enable = true; |
| 42 | |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 43 | services = { |
| 44 | ssh.enable = true; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 45 | headscale = { |
| 46 | enable = true; |
Skyler Grey | bed35f1 | 2024-07-04 00:46:44 +0000 | [diff] [blame] | 47 | domain = "clicks.domains"; |
Skyler Grey | 14375fe | 2024-06-22 14:43:44 +0000 | [diff] [blame] | 48 | addr = lib.clicks.constants.hosts.generic; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 49 | oidc = { |
| 50 | enable = true; |
| 51 | issuer = "https://login.clicks.codes/realms/master"; |
| 52 | allowed_groups = [ "/clicks" ]; |
| 53 | client_secret_path = |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 54 | config.age.secrets."clicks.services.headscale.oidc.client_secret_path".path; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 55 | }; |
| 56 | database_password_path = |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 57 | config.age.secrets."clicks.services.headscale.database_password_path".path; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 58 | noise_private_key_path = |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 59 | config.age.secrets."clicks.services.headscale.noise_private_key_path".path; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 60 | private_key_path = |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 61 | config.age.secrets."clicks.services.headscale.private_key_path".path; |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 62 | 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 Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 119 | "coded" |
Skyler Grey | efc6252 | 2024-06-15 00:23:06 +0000 | [diff] [blame] | 120 | "maddie" |
| 121 | "minion" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 122 | "pineafan" |
Skyler Grey | efc6252 | 2024-06-15 00:23:06 +0000 | [diff] [blame] | 123 | "zanderp25" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 124 | ]; |
Skyler Grey | 985a612 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 125 | groups."group:friends" = [ |
| 126 | "sirdigalot" |
| 127 | ]; |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 128 | groups."group:areas" = [ |
| 129 | # Some phonetic alphabet names are excluded here to avoid confusing |
| 130 | # them with given names |
| 131 | "alpha" |
| 132 | "bravo" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 133 | "echo" |
| 134 | "foxtrot" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 135 | "hotel" |
| 136 | "india" |
| 137 | "kilo" |
| 138 | "lima" |
| 139 | "november" |
| 140 | "papa" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 141 | "sierra" |
| 142 | "tango" |
| 143 | "uniform" |
| 144 | "whiskey" |
| 145 | "xray" |
| 146 | "yankee" |
| 147 | "zulu" |
| 148 | ]; |
| 149 | hosts.ipv6-internet = "2000::/3"; |
Skyler Grey | 2154d22 | 2024-06-10 17:17:51 +0000 | [diff] [blame] | 150 | |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 151 | acls = [ |
| 152 | { |
| 153 | action = "accept"; |
| 154 | src = [ "group:users" ]; |
| 155 | dst = [ |
| 156 | "group:users:*" |
Skyler Grey | 985a612 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 157 | "group:friends:*" |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 158 | "group:areas:*" |
| 159 | ] ++ (lib.forEach internet (host: "${host}:*")); |
| 160 | } |
| 161 | { |
| 162 | action = "accept"; |
Skyler Grey | 985a612 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 163 | src = [ "group:friends" ]; |
| 164 | dst = [ |
| 165 | "group:users:*" |
| 166 | "group:friends:*" |
| 167 | ]; |
| 168 | } |
| 169 | { |
| 170 | action = "accept"; |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 171 | src = [ "group:areas" ]; |
| 172 | dst = [ "group:areas:*" ]; |
| 173 | } |
Skyler Grey | 31fbc23 | 2024-08-22 16:34:53 +0000 | [diff] [blame] | 174 | { |
| 175 | action = "accept"; |
| 176 | src = [ "zulu" ]; |
| 177 | dst = [ "zanderp25:3000" ]; |
| 178 | } |
Skyler Grey | 0e05b52 | 2024-06-11 22:48:00 +0000 | [diff] [blame] | 179 | ]; |
| 180 | }; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 181 | }; |
Skyler Grey | 0a0912a | 2024-07-04 00:13:40 +0000 | [diff] [blame] | 182 | fava = { |
| 183 | enable = true; |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 184 | extraPythonPackages = [ |
| 185 | pkgs.clicks.beancount-autobean |
Skyler Grey | df6a636 | 2024-08-08 22:07:15 +0000 | [diff] [blame^] | 186 | pkgs.clicks.beancount-beancount_share |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 187 | pkgs.clicks.beancount-smart_importer |
| 188 | ]; |
Skyler Grey | 0a0912a | 2024-07-04 00:13:40 +0000 | [diff] [blame] | 189 | tailscaleAuth = true; |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 190 | credentials = { |
| 191 | truelayer_client_secret = config.age.secrets."clicks.services.fava.credentials.truelayer_client_secret".path; |
| 192 | }; |
Skyler Grey | 0a0912a | 2024-07-04 00:13:40 +0000 | [diff] [blame] | 193 | accounts = { |
Skyler Grey | 5e8bba2 | 2024-07-12 14:31:49 +0000 | [diff] [blame] | 194 | "clicks" = lib.home-manager.hm.dag.entryAnywhere { |
| 195 | name = "Clicks Codes"; |
| 196 | beancountExtraOptions.operating_currency = "GBP"; |
| 197 | }; |
| 198 | "coded" = lib.home-manager.hm.dag.entryBetween [ "testing" ] [ "clicks" ] { |
| 199 | name = "Samuel Shuert"; |
| 200 | beancountExtraOptions.operating_currency = "USD"; |
| 201 | }; |
| 202 | "minion" = lib.home-manager.hm.dag.entryBetween [ "testing" ] [ "clicks" ] { |
| 203 | name = "Skyler Grey"; |
| 204 | beancountExtraOptions.operating_currency = "GBP"; |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 205 | favaExtraOptions = { |
| 206 | invert-income-liabilities-equity = "true"; |
| 207 | auto-reload = "true"; |
Skyler Grey | df6a636 | 2024-08-08 22:07:15 +0000 | [diff] [blame^] | 208 | fiscal-year-end = "04-05"; |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 209 | import-config = builtins.toString (pkgs.writeText "minion-imports.py" '' |
| 210 | import autobean.truelayer |
| 211 | from smart_importer import apply_hooks, PredictPayees, PredictPostings |
| 212 | |
| 213 | import os |
| 214 | import pathlib |
| 215 | |
| 216 | with open(pathlib.Path(os.environ["CREDENTIALS_DIRECTORY"]) / pathlib.Path("truelayer_client_secret")) as f: |
| 217 | truelayer_client_secret = f.read().strip() |
| 218 | |
| 219 | CONFIG = [ |
| 220 | apply_hooks( |
| 221 | autobean.truelayer.Importer( |
| 222 | "fava-228732", |
| 223 | truelayer_client_secret |
| 224 | ), |
| 225 | [ |
| 226 | PredictPayees(), |
| 227 | PredictPostings(), |
| 228 | ] |
| 229 | ) |
| 230 | ] |
| 231 | ''); |
| 232 | import-dirs = "/var/lib/private/fava/minion/"; |
| 233 | }; |
Skyler Grey | df6a636 | 2024-08-08 22:07:15 +0000 | [diff] [blame^] | 234 | extraConfig = '' |
| 235 | plugin "fava.plugins.tag_discovered_documents" |
| 236 | plugin "fava.plugins.link_documents" |
| 237 | |
| 238 | plugin "beancount.plugins.pedantic" |
| 239 | plugin "beancount.plugins.unrealized" "Unrealized" |
| 240 | plugin "beancount.plugins.implicit_prices" |
| 241 | |
| 242 | plugin "beancount_share.share" "{ |
| 243 | 'mark_name': 'share', |
| 244 | 'meta_name': 'shared', |
| 245 | 'account_debtors': 'Assets:People', |
| 246 | 'account_creditors': 'Liabilities:People', |
| 247 | 'open_date': '1970-01-01', |
| 248 | 'quantize': '0.01' |
| 249 | }" |
| 250 | ''; |
Skyler Grey | 5e8bba2 | 2024-07-12 14:31:49 +0000 | [diff] [blame] | 251 | }; |
| 252 | "testing" = lib.home-manager.hm.dag.entryAfter [ "clicks" ] { |
| 253 | name = "Test Data - May Be Wiped At Any Time"; |
| 254 | }; |
Skyler Grey | 0a0912a | 2024-07-04 00:13:40 +0000 | [diff] [blame] | 255 | }; |
| 256 | domain = "fava.clicks.codes"; |
| 257 | }; |
Skyler Grey | 700577a | 2024-08-14 18:21:34 +0000 | [diff] [blame] | 258 | silverbullet = { |
| 259 | enable = true; |
| 260 | domain = "silverbullet.clicks.codes"; |
| 261 | tailscaleAuth = true; |
| 262 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 263 | }; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 264 | |
Skyler Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 265 | networking.tailscale = { |
| 266 | enable = true; |
| 267 | authKeyFile = |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 268 | config.age.secrets."clicks.networking.tailscale.authKeyFile".path; |
Skyler Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 269 | }; |
| 270 | |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 271 | storage = { |
Skyler Grey | f4d05f0 | 2024-06-06 21:25:39 +0000 | [diff] [blame] | 272 | raid.enable = true; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 273 | impermanence = { |
| 274 | enable = true; |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 275 | devices = { |
| 276 | root = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c"; |
| 277 | persist = "/dev/md/a1d1:persist"; |
| 278 | }; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 279 | }; |
| 280 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | boot.initrd.availableKernelModules = [ |
| 284 | "nvme" |
| 285 | "xhci_pci" |
| 286 | "ahci" |
| 287 | "usbhid" |
| 288 | "uas" |
| 289 | "usb_storage" |
| 290 | "sd_mod" |
| 291 | ]; |
| 292 | boot.initrd.kernelModules = [ ]; |
| 293 | boot.kernelModules = [ "kvm-amd" ]; |
| 294 | boot.extraModulePackages = [ ]; |
| 295 | |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 296 | fileSystems."/nix" = { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 297 | device = "/dev/disk/by-uuid/ab5c2f52-a737-4b29-a505-e3d0b9d0714c"; |
| 298 | fsType = "btrfs"; |
Skyler Grey | 40ae7a0 | 2024-06-06 21:22:25 +0000 | [diff] [blame] | 299 | options = [ "subvol=@nix" ]; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | fileSystems."/boot" = { |
| 303 | device = "/dev/disk/by-uuid/880D-BBAB"; |
| 304 | fsType = "vfat"; |
| 305 | options = [ |
| 306 | "fmask=0022" |
| 307 | "dmask=0022" |
| 308 | ]; |
| 309 | }; |
| 310 | |
| 311 | swapDevices = [ ]; |
| 312 | |
| 313 | networking.useDHCP = true; |
| 314 | |
| 315 | system.stateVersion = "24.05"; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 316 | |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 317 | age.secrets."clicks.networking.tailscale.authKeyFile".rekeyFile = ./clicks.networking.tailscale.authKeyFile.age; |
| 318 | |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 319 | age.secrets."clicks.security.acme.defaults.environmentFile".rekeyFile = ./clicks.security.acme.defaults.environmentFile.age; |
| 320 | |
Skyler Grey | 2c9c3e7 | 2024-07-17 22:00:16 +0000 | [diff] [blame] | 321 | age.secrets."clicks.services.fava.credentials.truelayer_client_secret".rekeyFile = ./clicks.services.fava.credentials.truelayer_client_secret.age; |
| 322 | |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 323 | age.secrets."clicks.services.headscale.oidc.client_secret_path" = { |
| 324 | rekeyFile = ./clicks.services.headscale.oidc.client_secret_path.age; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 325 | group = "headscale"; |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 326 | }; |
| 327 | age.secrets."clicks.services.headscale.database_password_path" = { |
| 328 | rekeyFile = ./clicks.services.headscale.database_password_path.age; |
| 329 | group = "headscale"; |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 330 | }; |
| 331 | age.secrets."clicks.services.headscale.noise_private_key_path" = { |
| 332 | rekeyFile = ./clicks.services.headscale.noise_private_key_path.age; |
| 333 | group = "headscale"; |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 334 | }; |
| 335 | age.secrets."clicks.services.headscale.private_key_path" = { |
| 336 | rekeyFile = ./clicks.services.headscale.private_key_path.age; |
| 337 | group = "headscale"; |
Skyler Grey | 61f0f85 | 2024-06-09 00:02:53 +0000 | [diff] [blame] | 338 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 339 | } |