From 4077f8281842e63c8d3a756bbde86cec01db3260 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 11:32:14 +1000 Subject: [PATCH 1/7] install syncthing --- modules/nixos/bundles/server.nix | 1 + modules/nixos/features/syncthing.nix | 36 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 modules/nixos/features/syncthing.nix diff --git a/modules/nixos/bundles/server.nix b/modules/nixos/bundles/server.nix index 117ca6b..235817b 100644 --- a/modules/nixos/bundles/server.nix +++ b/modules/nixos/bundles/server.nix @@ -19,6 +19,7 @@ in radarr.enable = true; radicale.enable = true; sonarr.enable = true; + syncthing.enable = true; qbittorrent.enable = true; vaultwarden.enable = true; vscode-server.enable = true; diff --git a/modules/nixos/features/syncthing.nix b/modules/nixos/features/syncthing.nix new file mode 100644 index 0000000..43e9fa0 --- /dev/null +++ b/modules/nixos/features/syncthing.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + userName, + ... +}: +let + feature = "syncthing"; + port = "5008"; +in +{ + config = lib.mkIf config.${feature}.enable { + services = { + # service + syncthing = { + enable = true; + guiAddress = "127.0.0.1:${port}"; + openDefaultPorts = true; + }; + + # reverse proxy + nginx = { + virtualHosts."${feature}.fi33.buzz" = { + forceSSL = true; + useACMEHost = "fi33.buzz"; + locations."/" = { + proxyPass = "http://localhost:${port}"; + # proxyWebsockets = true; + }; + }; + }; + }; + }; + + options.${feature}.enable = lib.mkEnableOption "enables ${feature}"; +} From b17e2c778680eee5d2c59936fe913a9ea09d32e7 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:44:21 +1000 Subject: [PATCH 2/7] configure syncthing to work on all devices --- modules/nixos/default.nix | 1 + modules/nixos/features/syncthing.nix | 44 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 26b70e2..6db4225 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -20,6 +20,7 @@ in nix-settings.enable = lib.mkDefault true; nixpkgs.enable = lib.mkDefault true; nixvim.enable = lib.mkDefault true; + syncthing.enable = lib.mkDefault true; systemd-boot.enable = lib.mkDefault true; tailscale.enable = lib.mkDefault true; diff --git a/modules/nixos/features/syncthing.nix b/modules/nixos/features/syncthing.nix index 43e9fa0..ac40f50 100644 --- a/modules/nixos/features/syncthing.nix +++ b/modules/nixos/features/syncthing.nix @@ -2,11 +2,47 @@ config, lib, userName, + hostName, ... }: let feature = "syncthing"; port = "5008"; + + devicesList = [ + { + device = "desktop"; + id = ""; + } + { + device = "laptop"; + id = ""; + } + { + device = "phone"; + id = "DF56S5M-2EDKAML-LZBB35J-MNNK7UE-WAYE2QW-EKUGKXN-U5JW3RX-S3FUGA4"; + } + { + device = "server"; + id = "OP7EU3A-7A4CCMY-D4T3ND7-YWMRBNJ-KVE34FG-ZJQFSLS-WMLRWB4-FL2O7AZ"; + } + ]; + + devices = builtins.listToAttrs ( + map ( + { device, id }: + { + name = device; + value = { + addresses = [ + "tcp://${device}:22000" + ]; + autoAcceptFolders = true; + inherit id; + }; + } + ) (builtins.filter (deviceSet: deviceSet.device != hostName) devicesList) + ); in { config = lib.mkIf config.${feature}.enable { @@ -14,8 +50,14 @@ in # service syncthing = { enable = true; - guiAddress = "127.0.0.1:${port}"; + guiAddress = "0.0.0.0:${port}"; openDefaultPorts = true; + user = "${userName}"; + dataDir = "/home/${userName}"; + overrideDevices = true; + settings = { + inherit devices; + }; }; # reverse proxy From 18edfad530051234a9b9a0933339680b458b03a2 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:01:15 +1000 Subject: [PATCH 3/7] add desktop ID --- modules/nixos/features/syncthing.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/features/syncthing.nix b/modules/nixos/features/syncthing.nix index ac40f50..80f344f 100644 --- a/modules/nixos/features/syncthing.nix +++ b/modules/nixos/features/syncthing.nix @@ -12,7 +12,7 @@ let devicesList = [ { device = "desktop"; - id = ""; + id = "SKDADYB-DQVC2EG-BZ67OJR-DO25ZUR-URP2G5U-FXRNC65-OWPEKHN-STTRRQG"; } { device = "laptop"; From 0ae6454a91c466046addb9d1086b56e48ca90407 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:21:01 +1000 Subject: [PATCH 4/7] add database files to backup --- modules/nixos/features/borgbackup-srv.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/nixos/features/borgbackup-srv.nix b/modules/nixos/features/borgbackup-srv.nix index 40839df..9456d89 100644 --- a/modules/nixos/features/borgbackup-srv.nix +++ b/modules/nixos/features/borgbackup-srv.nix @@ -38,7 +38,10 @@ in services.borgbackup.jobs = let srv = location: { - paths = "/srv"; + paths = [ + "/srv" + "/home/srv/.config/syncthing" + ]; compression = "auto,zstd"; From e79c3241fe6e9f9937c39f0231a1012c26b2c3ea Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:56:59 +1000 Subject: [PATCH 5/7] add syncthing to dashboard --- modules/nixos/features/homepage-dashboard.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/nixos/features/homepage-dashboard.nix b/modules/nixos/features/homepage-dashboard.nix index b3bdc88..a531e73 100644 --- a/modules/nixos/features/homepage-dashboard.nix +++ b/modules/nixos/features/homepage-dashboard.nix @@ -190,6 +190,13 @@ in "href" = "https://radicale.fi33.buzz/"; }; } + { + "Syncthing" = { + "description" = "Decentralised file synchronisation"; + "icon" = "syncthing.svg"; + "href" = "https://syncthing.fi33.buzz/"; + }; + } { "qBittorrent" = { "description" = "BitTorrent client"; From 29525e168cd2c9adf05dd10f3f9480367b50f9f3 Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:30:54 +1000 Subject: [PATCH 6/7] add synced files to backup --- modules/nixos/features/borgbackup-srv.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nixos/features/borgbackup-srv.nix b/modules/nixos/features/borgbackup-srv.nix index 9456d89..5766c24 100644 --- a/modules/nixos/features/borgbackup-srv.nix +++ b/modules/nixos/features/borgbackup-srv.nix @@ -41,6 +41,7 @@ in paths = [ "/srv" "/home/srv/.config/syncthing" + "/home/srv/Sync" ]; compression = "auto,zstd"; From 45f341811f390aa0876a5d5f8f2aa6266e23c38d Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 20 Aug 2025 14:02:05 +1000 Subject: [PATCH 7/7] add laptop id --- modules/nixos/features/syncthing.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/features/syncthing.nix b/modules/nixos/features/syncthing.nix index 80f344f..710b3e3 100644 --- a/modules/nixos/features/syncthing.nix +++ b/modules/nixos/features/syncthing.nix @@ -16,7 +16,7 @@ let } { device = "laptop"; - id = ""; + id = "XDDGWB2-5OFYWSY-7LN652V-3WNQMWV-4WCVHCR-2EXLDW7-FUL2MC4-MMLO4QV"; } { device = "phone";