From f88552ad646511b297539960fc3241956dccb045 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 26 Jan 2021 20:59:10 -0500 Subject: [PATCH] Add modules/services/syncthing.nix Generalizes the module so it's not so Henrik-centric. I know, blasphemous, but the world only sometimes revolves around me. Also, adds a new, much simpler config for syncthing. --- hosts/personal.nix | 18 ++++++++++++++++++ modules/services/syncthing.nix | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 modules/services/syncthing.nix diff --git a/hosts/personal.nix b/hosts/personal.nix index 7f7673dc..75fda916 100644 --- a/hosts/personal.nix +++ b/hosts/personal.nix @@ -28,4 +28,22 @@ with lib; ## modules.shell.bitwarden.config.server = "p.v0.io"; + + services.syncthing.declarative = { + devices = { + kuro.id = "4UJSUBN-V7LCISG-6ZE7SBN-YPXM5FQ-CE7CD2U-W4KZC7O-4HUZZSW-6DXAGQQ"; + shiro.id = "G4DUO25-AMQQIWS-SRZE5TJ-43CCQZJ-5ULEZBS-P2LMZZU-V5JA5CS-6X7RLQK"; + kiiro.id = "DPQT4XQ-Q4APAYJ-T7P4KMY-YBLDKLC-7AU5Y4S-VGT3DDT-TMZZEIX-GBA7DAM"; + }; + folders = + let mkShare = name: devices: type: path: rec { + inherit devices type path; + watch = false; + rescanInterval = 3600 * 4; + enabled = lib.elem config.networking.hostname devices; + }; + in { + projects = mkShare "projects" [ "kuro" "shiro" ] "sendrecieve" "${config.user.home}/projects"; + }; + }; } diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix new file mode 100644 index 00000000..41644822 --- /dev/null +++ b/modules/services/syncthing.nix @@ -0,0 +1,20 @@ +{ config, options, pkgs, lib, ... }: + +with lib; +with lib.my; +let cfg = config.modules.services.syncthing; +in { + options.modules.services.syncthing = { + enable = mkBoolOpt false; + }; + + config = mkIf cfg.enable { + services.syncthing = rec { + enable = true; + openDefaultPorts = true; + user = config.user.name; + configDir = "/home/${user}/.config/syncthing"; + dataDir = "/home/${user}/.local/share/syncthing"; + }; + }; +}