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"; + }; + }; +}