diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-06-13 15:02:58 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-06-13 15:02:58 +0530 |
| commit | fb3c68a676643e60e396daf4076684e12d157677 (patch) | |
| tree | 16a6ee14a9d745079e99a066ad30efda1f947e72 /modules/network | |
| parent | e6b171f9f1d975ffe34e7a34743b5e92e8593847 (diff) | |
| download | homeserver-nixos-config-fb3c68a676643e60e396daf4076684e12d157677.tar.gz homeserver-nixos-config-fb3c68a676643e60e396daf4076684e12d157677.zip | |
Syncthing + service router refactor
Diffstat (limited to '')
| -rw-r--r-- | modules/network/default.nix | 16 | ||||
| -rw-r--r-- | modules/network/service-router.service.nix (renamed from modules/service-router.service.nix) | 7 |
2 files changed, 21 insertions, 2 deletions
diff --git a/modules/network/default.nix b/modules/network/default.nix index ee3462c..6a40ef7 100644 --- a/modules/network/default.nix +++ b/modules/network/default.nix @@ -1,12 +1,28 @@ { lib, ... }: let settings = import ../../settings.nix { inherit lib; }; + ports = settings.network.ports; + host = settings.network.host; in { imports = [ ./ssh.nix + ./service-router.service.nix ]; + services.service-router = { + enable = true; + routes = { + "home.local" = { inherit host; port = ports.dashboard; }; + "sonarr.local" = { inherit host; port = ports.sonarr; }; + "radarr.local" = { inherit host; port = ports.radarr; }; + "prowlarr.local" = { inherit host; port = ports.prowlarr; }; + "jellyfin.local" = { inherit host; port = ports.jellyfin; }; + "syncthing.local" = { inherit host; port = ports.syncthing; }; + "lidarr.local" = { inherit host; port = ports.lidarr; }; + }; + }; + networking = { hostName = "bacchus"; diff --git a/modules/service-router.service.nix b/modules/network/service-router.service.nix index 0b9a873..9c4e6e2 100644 --- a/modules/service-router.service.nix +++ b/modules/network/service-router.service.nix @@ -19,6 +19,7 @@ in { port = mkOption { type = types.int; }; host = mkOption { type = types.str; default = "127.0.0.1"; }; protocol = mkOption { type = types.str; default = "http"; }; + nginx = mkOption { type = types.attrs; default = {}; }; }; }); default = {}; }; @@ -27,10 +28,12 @@ in { config = lib.mkIf cfg.enable { services.nginx = { enable = true; + recommendedOptimisation = true; virtualHosts = lib.mapAttrs (_: val: { - locations."/" = { + locations."/" = if val.nginx == {} then { proxyPass = "${val.protocol}://${val.host}:${toString val.port}"; - }; + proxyWebsockets = true; + } else val.nginx; }) cfg.routes; }; |
