{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.home.roles.sync;
  isLinux = pkgs.stdenv.isLinux;
in
{
  options.home.roles.sync = {
    enable = mkEnableOption "Enable file synchronization services";
  };

  config = mkIf cfg.enable {
    # Linux-only: syncthingtray requires system tray support
    home.packages = optionals isLinux (with pkgs; [
      syncthingtray
    ]);

    services.syncthing = {
      enable = true;
    };
  };
}