From c18309aead558b469ed2bdc23b21cf9fac51f402 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Wed, 3 Dec 2025 13:45:30 +0100 Subject: [PATCH] add syncthing to vps --- hosts/nixos/vps/home.nix | 6 ++++++ modules/syncthing.nix | 18 +++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/hosts/nixos/vps/home.nix b/hosts/nixos/vps/home.nix index bdd9801..577e17b 100644 --- a/hosts/nixos/vps/home.nix +++ b/hosts/nixos/vps/home.nix @@ -3,5 +3,11 @@ { imports = [ ../home-default.nix + ../../../modules/syncthing.nix ]; + + syncthing-custom = { + enabledFolders = [ "Credentials" ]; + enableGui = false; + }; } diff --git a/modules/syncthing.nix b/modules/syncthing.nix index c6a59a6..0df5652 100644 --- a/modules/syncthing.nix +++ b/modules/syncthing.nix @@ -22,11 +22,10 @@ let stignoreContent = lib.concatStringsSep "\n" commonIgnores; # Device groupings - nixosDevices = [ "hs" "thinkpad" ]; - darwinDevices = [ "macbook" ]; + pcDevices = [ "macbook" "hs" "thinkpad" ]; touchDevices = [ "iphone" "ipad" ]; - pcDevices = nixosDevices ++ darwinDevices; - allDevices = pcDevices ++ touchDevices; + cloudDevices = [ "vps" ]; + allDevices = pcDevices ++ touchDevices ++ cloudDevices; # Common versioning configuration commonVersioning = { @@ -44,6 +43,11 @@ in default = [ "Credentials" "Documents" "Archive" ]; description = "List of Syncthing folders to enable for this host."; }; + enableGui = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to enable the Syncthing web GUI."; + }; }; config = { @@ -54,7 +58,7 @@ in tray.enable = false; # Listen on all interfaces for the GUI - guiAddress = "0.0.0.0:8384"; + guiAddress = lib.mkIf cfg.enableGui "0.0.0.0:8384"; # Declarative configuration - will override any GUI changes overrideDevices = true; @@ -101,7 +105,7 @@ in // (lib.optionalAttrs (lib.elem "Archive" cfg.enabledFolders) { "Archive" = { path = "~/Archive"; - devices = allDevices; + devices = pcDevices ++ touchDevices; ignorePerms = true; versioning = commonVersioning; }; @@ -109,7 +113,7 @@ in # GUI settings with authentication gui = { - enabled = true; + enabled = cfg.enableGui; user = "yanlin"; useTLS = false; };