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.
This commit is contained in:
Henrik Lissner 2021-01-26 20:59:10 -05:00
parent 41ac027216
commit f88552ad64
2 changed files with 38 additions and 0 deletions

View file

@ -28,4 +28,22 @@ with lib;
## ##
modules.shell.bitwarden.config.server = "p.v0.io"; 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";
};
};
} }

View file

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