{
  lib,
  config,
  pkgs,
  ...
}:
let
  inherit (lib) mkEnableOption mkIf;

  cfg = config.marleyos.services.syncthing;
in
{
  options.marleyos.services.syncthing.enable = mkEnableOption "syncthing";

  config = mkIf cfg.enable {
    home.packages = [
      config.services.syncthing.tray.package
    ];

    services.syncthing = {
      enable = true;

      tray = {
        enable = true;
        command = "syncthingtray";
        package = pkgs.syncthingtray-minimal;
      };
    };
  };
}
