{ pkgs, ... }:
let
  obs-wrapped = (pkgs.obs-studio.override {
    cudaSupport = true;
  }).overrideAttrs (old: {
    nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ pkgs.makeWrapper ];
    postInstall = (old.postInstall or "") + ''
      wrapProgram $out/bin/obs \
        --set QT_QPA_PLATFORM xcb \
        --set GS_DEVICE_TYPE opengl
    '';
  });
in
{
  programs.obs-studio = {
    enable = true;
    package = obs-wrapped;

    plugins = with pkgs.obs-studio-plugins; [
      obs-backgroundremoval
      obs-pipewire-audio-capture
      obs-vaapi
      obs-gstreamer
      obs-vkcapture
      obs-move-transition
    ];
  };
}