{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.jade.desktop.media.obs;
in
with lib;
{
  options.jade.desktop.media.obs = mkEnableOption "Enable OBS";

  config = mkIf cfg {
    programs.obs-studio.enableVirtualCamera = true;
    # OBS stuffs
    environment.systemPackages = [
      (pkgs.wrapOBS {
        plugins = with pkgs.obs-studio-plugins; [
          wlrobs
          obs-backgroundremoval
          obs-pipewire-audio-capture
          waveform
          obs-3d-effect
        ];
      })
    ];

    boot = {
      extraModulePackages = with config.boot.kernelPackages; [
        v4l2loopback
      ];
      extraModprobeConfig = ''
        options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1
      '';
    };
  };
}
