{ config, ... }:
let
  host = config.networking.hostName;
in
{

  sops.secrets."syncthing/key.pem" = {
    sopsFile = ../../hosts/${host}/secrets/default.yaml;
  };
  sops.secrets."syncthing/cert.pem" = {
    sopsFile = ../../hosts/${host}/secrets/default.yaml;
  };

  services.syncthing = {
    enable = true;

    user = "lilith";
    dataDir = "/home/lilith";
    configDir = "/home/lilith/.config/syncthing";

    overrideDevices = true;
    overrideFolders = true;

    key = config.sops.secrets."syncthing/key.pem".path;
    cert = config.sops.secrets."syncthing/cert.pem".path;

    settings = {
      devices = {
        "lilith-phone" = {
          id = "N3VHPZJ-DARZYPM-TIBLRAZ-KN6QWYJ-VU6FP2N-INYVJZ3-ZSUD63P-NSXLIQ6";
        };
        "lilith-lab" = {
          id = "DW6GTZ3-3JPAHLO-UEB3LBL-AWOX3BT-QPI7ODT-OZ6Q4YR-K3KK22C-5RY3XQZ";
        };
        "lilith-pc" = {
          id = "ZXFUFLA-MJJCNE4-SJTGTYD-SEJZUCX-3KIFTL6-LFIWBBU-HD2LX2F-7FQ5VAF";
        };
        "lilith-pad" = {
          id = "GQJA6WA-G5YZZSN-4OOQMVE-JPIR22N-VFHPY4O-XMRG37D-DALH4R2-7DCTMQK";
        };
      };
      folders = {
        "sync" = {
          id = "rdcj2-mfyb4";
          path = "/home/lilith/sync";
          devices = [
            "lilith-phone"
            "lilith-lab"
            "lilith-pad"
            "lilith-pc"
          ];
        };
        "keepass" = {
          id = "sdpfs-2beqd";
          path = "/home/lilith/.keepass";
          devices = [
            "lilith-phone"
            "lilith-lab"
            "lilith-pad"
            "lilith-pc"
          ];
        };
      };
    };
  };
}
