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

with lib;

let
  cfg = config.home.roles.communication;
  isLinux = pkgs.stdenv.isLinux;
in
{
  options.home.roles.communication = {
    enable = mkEnableOption "Enable communication and messaging applications";
  };

  config = mkIf cfg.enable {
    home.packages = [
      # For logging back into google chat (cross-platform)
      globalInputs.google-cookie-retrieval.packages.${system}.default
    ] ++ optionals isLinux [
      # Linux-only communication apps (Electron apps don't build on Darwin)
      pkgs.element-desktop
      # Re-enabled in 25.11 after security issues were resolved
      pkgs.fluffychat
      pkgs.nextcloud-talk-desktop
    ];
  };
}
