From 905eb9652f0259c979122656dee633c7693bf080 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 31 Dec 2024 16:17:44 +0200 Subject: [PATCH] Added syncthing --- host/configuration.nix | 1 + nixosModules/syncthing.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 nixosModules/syncthing.nix diff --git a/host/configuration.nix b/host/configuration.nix index 5e3e73c..6ae97f5 100644 --- a/host/configuration.nix +++ b/host/configuration.nix @@ -37,6 +37,7 @@ website.enable = true; actualBudget.enable = true; gitea.enable = true; + syncthing.enable = true # Automatically pull this config from git autoUpdate.enable = true; diff --git a/nixosModules/syncthing.nix b/nixosModules/syncthing.nix new file mode 100644 index 0000000..e572fd9 --- /dev/null +++ b/nixosModules/syncthing.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, config, ... }: { + + options = { + syncthing.enable = lib.mkEnableOption "enables syncthing"; + }; + + config = lib.mkIf config.syncthing.enable { + + # 22000 TCP and/or UDP for sync traffic + # 21027/UDP for discovery + networking.firewall.allowedTCPPorts = [ 22000 ]; + networking.firewall.allowedUDPPorts = [ 22000 21027 ]; + + servicessyncthing = { + enable = true; + group = "syncthing"; + user = "syncthing"; + dataDir = "/home/syncthing/data"; + configDir = "/home/syncthing/config"; + overrideDevices = true; + overrideFolders = true; + settings = { + devices = { + "kyren-laptop" = { id = "XV2ODEO-KBUQSZD-ZNAJD3N-FV4M64X-RQG4NLD-FUIMUL3-OWGNMS4-S5XTDAO"; }; + }; + folders = { }; + }; + }; + }; +}