From fb3c68a676643e60e396daf4076684e12d157677 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 13 Jun 2025 15:02:58 +0530 Subject: Syncthing + service router refactor --- modules/service-router.service.nix | 49 -------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 modules/service-router.service.nix (limited to 'modules/service-router.service.nix') diff --git a/modules/service-router.service.nix b/modules/service-router.service.nix deleted file mode 100644 index 0b9a873..0000000 --- a/modules/service-router.service.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ config, lib, dns, ... }: -with lib; -let - cfg = config.services.service-router; - domainAZone = domain: record: { - A = [ record ]; - SOA = { - nameServer = "ns.${domain}."; - adminEmail = "dont@email.me"; - serial = 2019030800; - }; - NS = [ "ns.${domain}." ]; - }; -in { - options.services.service-router = { - enable = mkEnableOption "enable router"; - routes = mkOption { - type = types.attrsOf (types.submodule { options = { - port = mkOption { type = types.int; }; - host = mkOption { type = types.str; default = "127.0.0.1"; }; - protocol = mkOption { type = types.str; default = "http"; }; - }; }); - default = {}; - }; - }; - - config = lib.mkIf cfg.enable { - services.nginx = { - enable = true; - virtualHosts = lib.mapAttrs (_: val: { - locations."/" = { - proxyPass = "${val.protocol}://${val.host}:${toString val.port}"; - }; - }) cfg.routes; - }; - - services.nsd = { - enable = true; - interfaces = [ "0.0.0.0" ]; - zones = lib.mapAttrs (domain: val: { - data = dns.lib.toString domain (domainAZone domain val.host); - }) cfg.routes; - }; - networking.firewall.allowedTCPPorts = [ 53 ]; - networking.firewall.allowedUDPPorts = [ 53 ]; - - networking.hosts."127.0.0.1" = lib.mapAttrsToList (name: _: name) cfg.routes; - }; -} -- cgit v1.3.1