From af3d33339593cc8bb13b71194ad2ba1eb2741fc6 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Fri, 13 Jun 2025 19:06:20 +0200 Subject: [PATCH] Set syncthing ports with options --- modules/system/services/syncthing/default.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/system/services/syncthing/default.nix b/modules/system/services/syncthing/default.nix index 65430a4..804095a 100644 --- a/modules/system/services/syncthing/default.nix +++ b/modules/system/services/syncthing/default.nix @@ -16,6 +16,14 @@ in type = lib.types.nonEmptyStr; default = ""; }; + syncPort = lib.mkOption { + type = lib.types.port; + default = 22000; + }; + guiPort = lib.mkOption { + type = lib.types.port; + default = 8384; + }; }; config = lib.mkIf cfg.enable { @@ -33,7 +41,7 @@ in group = lib.mkIf (!cfg.isServer) "users"; dataDir = lib.mkIf (!cfg.isServer) "/home/seb"; - guiAddress = lib.mkIf cfg.isServer "0.0.0.0:8384"; + guiAddress = lib.mkIf cfg.isServer "0.0.0.0:${toString cfg.guiPort}"; settings = { # Get the devices and their ids from the configs of the other hosts @@ -44,7 +52,7 @@ in |> lib.mapAttrs ( name: value: { id = value.config.custom.services.syncthing.deviceId; - addresses = [ "tcp://${name}.${tailscaleCfg.domain}:22000" ]; + addresses = [ "tcp://${name}.${tailscaleCfg.domain}:${toString cfg.syncPort}" ]; } ); @@ -68,6 +76,7 @@ in ]; options = { + listenAddress = "tcp://0.0.0.0:${toString cfg.syncPort}"; globalAnnounceEnabled = false; localAnnounceEnabled = false; relaysEnabled = false;