From aeea92d752751eb096debf7247aa2f608ef00519 Mon Sep 17 00:00:00 2001 From: 4DBug <4DBug@github.com> Date: Tue, 3 Mar 2026 17:25:37 -0600 Subject: [PATCH] organize --- modules/{ => core}/infra/cloudflared.nix | 6 +- modules/core/infra/syncthing.nix | 42 ++++++++++++++ modules/hosts/{box => }/box.nix | 9 --- modules/hosts/{nix/nix.nix => common.nix} | 21 +------ modules/hosts/defaults.nix | 13 ++++- modules/hosts/laptop.nix | 20 +++++++ modules/hosts/laptop/laptop.nix | 49 ---------------- modules/hosts/nix.nix | 13 +++++ modules/infra/syncthing.nix | 70 ----------------------- modules/services/ports.nix | 17 ++++-- modules/services/redlib.nix | 2 +- portmap.nix | 10 ---- 12 files changed, 104 insertions(+), 168 deletions(-) rename modules/{ => core}/infra/cloudflared.nix (86%) create mode 100644 modules/core/infra/syncthing.nix rename modules/hosts/{box => }/box.nix (84%) rename modules/hosts/{nix/nix.nix => common.nix} (53%) create mode 100644 modules/hosts/laptop.nix delete mode 100644 modules/hosts/laptop/laptop.nix create mode 100644 modules/hosts/nix.nix delete mode 100644 modules/infra/syncthing.nix delete mode 100644 portmap.nix diff --git a/modules/infra/cloudflared.nix b/modules/core/infra/cloudflared.nix similarity index 86% rename from modules/infra/cloudflared.nix rename to modules/core/infra/cloudflared.nix index 20e2b4c..5fb2ad1 100644 --- a/modules/infra/cloudflared.nix +++ b/modules/core/infra/cloudflared.nix @@ -7,7 +7,7 @@ in { nixos = { config, pkgs, lib, ... }: { options.den.tunnels = lib.mkOption { default = []; - description = "Cloudflared tunnel subdomains, matched directly against portmap keys."; + description = "cloudflared tunnels"; type = lib.types.listOf lib.types.str; }; @@ -20,7 +20,7 @@ in { tunnels.${uuid} = { credentialsFile = "/etc/cloudflared/${uuid}.json"; - default = "http_status:404"; + default = "http_status:404"; ingress = lib.listToAttrs (map (subdomain: { name = "${subdomain}.${domain}"; @@ -31,4 +31,4 @@ in { }; }; }; -} \ No newline at end of file +} diff --git a/modules/core/infra/syncthing.nix b/modules/core/infra/syncthing.nix new file mode 100644 index 0000000..7c8f3d8 --- /dev/null +++ b/modules/core/infra/syncthing.nix @@ -0,0 +1,42 @@ +{ + den.aspects.syncthing = { + homeManager = let + devices = ["desktop" "laptop" "server"]; + + mkFolder = path: { + inherit path; + devices = devices; + }; + in { + services.syncthing = { + enable = true; + + overrideDevices = true; + overrideFolders = true; + + key = "/home/bug/.syncthing/key.pem"; + cert = "/home/bug/.syncthing/cert.pem"; + + settings = { + devices = { + desktop.id = "VEZXY3W-U6UXWTP-6BHANIG-O5EKNZY-XNV5YOX-4V4O3HB-ETECIUX-T2DK7AV"; + laptop.id = "I6NW53P-IJMMT73-7O53TXY-3GAHS2U-4EAADM7-ZNB5ZPB-62QHKVW-H7DYXQ2"; + server.id = "KJECAIP-Y2Y3FHV-NOJKIQV-LWIDMMZ-5ITEAZ4-LQCQL72-3BGW6T7-BFPFJQA"; + }; + + folders = { + "Documents" = mkFolder "/home/bug/Documents"; + "Downloads" = mkFolder "/home/bug/Downloads"; + "Pictures" = mkFolder "/home/bug/Pictures"; + "Videos" = mkFolder "/home/bug/Videos"; + "Music" = mkFolder "/home/bug/Music"; + "nix" = mkFolder "/home/bug/nix"; + "hytale" = mkFolder "/home/bug/.local/share/Hytale/UserData/Saves"; + "ssh" = mkFolder "/home/bug/.ssh"; + "cloudflared" = mkFolder "/home/bug/.cloudflared"; + }; + }; + }; + }; + }; +} diff --git a/modules/hosts/box/box.nix b/modules/hosts/box.nix similarity index 84% rename from modules/hosts/box/box.nix rename to modules/hosts/box.nix index a6761f5..306315d 100644 --- a/modules/hosts/box/box.nix +++ b/modules/hosts/box.nix @@ -2,17 +2,8 @@ den.aspects.box = { includes = with den.aspects; [ den.default - den.provides.home-manager - - dns - openssh cloudflared - syncthing - - catppuccin - - fish portmap searxng diff --git a/modules/hosts/nix/nix.nix b/modules/hosts/common.nix similarity index 53% rename from modules/hosts/nix/nix.nix rename to modules/hosts/common.nix index 9b329de..491b715 100644 --- a/modules/hosts/nix/nix.nix +++ b/modules/hosts/common.nix @@ -1,11 +1,7 @@ -{ den, ... }: -{ - den.aspects.nix = { +{ den, ... }: { + den.aspects.common = { includes = with den.aspects; [ den.default - den.provides.home-manager - - nvidia cosmic audio @@ -13,19 +9,10 @@ swap virtualisation - dns - openssh - # cloudflare-warp - - syncthing - stylix - catppuccin - fish flatpak development - # cad compatibility utilities @@ -36,9 +23,5 @@ social gaming ]; - - nixos = { - networking.hostName = "nix"; - }; }; } diff --git a/modules/hosts/defaults.nix b/modules/hosts/defaults.nix index 224a73a..f92ffd4 100644 --- a/modules/hosts/defaults.nix +++ b/modules/hosts/defaults.nix @@ -1,10 +1,21 @@ { den, ... }: { den.default = { includes = with den.aspects; [ + den.provides.home-manager + boot security locale essentials + + dns + openssh + syncthing + + catppuccin + fish + + janitor ]; nixos = { ... }: { @@ -36,4 +47,4 @@ home.stateVersion = "26.05"; }; }; -} \ No newline at end of file +} diff --git a/modules/hosts/laptop.nix b/modules/hosts/laptop.nix new file mode 100644 index 0000000..e04ac91 --- /dev/null +++ b/modules/hosts/laptop.nix @@ -0,0 +1,20 @@ +{ den, ... }: { + den.aspects.laptop = { + includes = with den.aspects; [ + common + + amdgpu + cloudflare-warp + cad + ]; + + nixos = { + networking.hostName = "nix"; + + services.logind.settings.Login = { + HandleLidSwitch = "ignore"; + HandleLidSwitchDocked = "ignore"; + }; + }; + }; +} diff --git a/modules/hosts/laptop/laptop.nix b/modules/hosts/laptop/laptop.nix deleted file mode 100644 index d89a884..0000000 --- a/modules/hosts/laptop/laptop.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ den, ... }: { - den.aspects.laptop = { - includes = with den.aspects; [ - den.default - den.provides.home-manager - - amdgpu - - cosmic - audio - - swap - virtualisation - - dns - openssh - cloudflare-warp - - syncthing - - stylix - catppuccin - - fish - flatpak - development - cad - compatibility - utilities - janitor - - firefox - librewolf - - music - social - gaming - ]; - - nixos = { - networking.hostName = "nix"; - - services.logind.settings.Login = { - HandleLidSwitch = "ignore"; - HandleLidSwitchDocked = "ignore"; - }; - }; - }; -} diff --git a/modules/hosts/nix.nix b/modules/hosts/nix.nix new file mode 100644 index 0000000..b652d4f --- /dev/null +++ b/modules/hosts/nix.nix @@ -0,0 +1,13 @@ +{ den, ... }: { + den.aspects.nix = { + includes = with den.aspects; [ + common + + nvidia + ]; + + nixos = { + networking.hostName = "nix"; + }; + }; +} diff --git a/modules/infra/syncthing.nix b/modules/infra/syncthing.nix deleted file mode 100644 index 9a967e8..0000000 --- a/modules/infra/syncthing.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - den.aspects.syncthing = { - homeManager = { - services.syncthing = { - enable = true; - - overrideDevices = true; - overrideFolders = true; - - key = "/home/bug/.syncthing/key.pem"; - cert = "/home/bug/.syncthing/cert.pem"; - - settings = { - devices = { - desktop.id = "VEZXY3W-U6UXWTP-6BHANIG-O5EKNZY-XNV5YOX-4V4O3HB-ETECIUX-T2DK7AV"; - laptop.id = "I6NW53P-IJMMT73-7O53TXY-3GAHS2U-4EAADM7-ZNB5ZPB-62QHKVW-H7DYXQ2"; - server.id = "KJECAIP-Y2Y3FHV-NOJKIQV-LWIDMMZ-5ITEAZ4-LQCQL72-3BGW6T7-BFPFJQA"; - }; - - folders = { - "Documents" = { - path = "/home/bug/Documents"; - devices = ["desktop" "laptop" "server"]; - }; - - "Downloads" = { - path = "/home/bug/Downloads"; - devices = ["desktop" "laptop" "server"]; - }; - - "Pictures" = { - path = "/home/bug/Pictures"; - devices = ["desktop" "laptop" "server"]; - }; - - "Videos" = { - path = "/home/bug/Videos"; - devices = ["desktop" "laptop" "server"]; - }; - - "nix" = { - path = "/home/bug/nix"; - devices = ["desktop" "laptop" "server"]; - }; - - "hytale" = { - path = "/home/bug/.local/share/Hytale/UserData/Saves"; - devices = ["desktop" "laptop"]; - }; - - "ssh" = { - path = "/home/bug/.ssh"; - devices = ["desktop" "laptop" "server"]; - }; - - "cloudflared" = { - path = "/home/bug/.cloudflared"; - devices = ["desktop" "laptop" "server"]; - }; - - "Music" = { - path = "/home/bug/Music/"; - devices = ["desktop" "laptop" "server"]; - }; - }; - }; - }; - }; - }; -} diff --git a/modules/services/ports.nix b/modules/services/ports.nix index 66c4566..2117e77 100644 --- a/modules/services/ports.nix +++ b/modules/services/ports.nix @@ -1,7 +1,12 @@ -{ lib, ... }: { - den.aspects.portmap.nixos.options.den.portmap = lib.mkOption { - type = lib.types.attrsOf lib.types.port; - readOnly = true; - default = import ../../../portmap.nix; +{ + den.aspects.portmap.nixos.options.den.portmap = { + tvtun = 3001; + search = 8888; + files = 3210; + tube = 3030; + reddit = 8975; + git = 3002; + monitor = 61208; + matrix = 8008; }; -} \ No newline at end of file +} diff --git a/modules/services/redlib.nix b/modules/services/redlib.nix index fcc0fcf..624be18 100644 --- a/modules/services/redlib.nix +++ b/modules/services/redlib.nix @@ -8,7 +8,7 @@ address = "127.0.0.1"; port = config.den.portmap.reddit; - openFirewall = false; + openFirewall = true; settings = { SFW_ONLY = "off"; diff --git a/portmap.nix b/portmap.nix deleted file mode 100644 index d28215e..0000000 --- a/portmap.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - tvtun = 3001; - search = 8888; - files = 3210; - tube = 3030; - reddit = 8975; - git = 3002; - monitor = 61208; - matrix = 8008; -} \ No newline at end of file