Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-studio: override libcef with obs build #317589

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
261 changes: 143 additions & 118 deletions pkgs/applications/video/obs-studio/default.nix
Original file line number Diff line number Diff line change
@@ -1,63 +1,73 @@
{ config
, lib
, stdenv
, fetchFromGitHub
, fetchpatch
, addOpenGLRunpath
, cmake
, fdk_aac
, ffmpeg
, jansson
, libjack2
, libxkbcommon
, libpthreadstubs
, libXdmcp
, qtbase
, qtsvg
, speex
, libv4l
, x264
, curl
, wayland
, xorg
, pkg-config
, libvlc
, libGL
, mbedtls
, wrapGAppsHook3
, scriptingSupport ? true
, luajit
, swig4
, python3
, alsaSupport ? stdenv.isLinux
, alsa-lib
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux
, libpulseaudio
, libcef
, pciutils
, pipewireSupport ? stdenv.isLinux
, withFdk ? true
, pipewire
, libdrm
, libajantv2
, librist
, libva
, srt
, qtwayland
, wrapQtAppsHook
, nlohmann_json
, websocketpp
, asio
, decklinkSupport ? false
, blackmagic-desktop-video
, libdatachannel
, libvpl
, qrcodegencpp
, nix-update-script
{
config,
lib,
stdenv,
fetchurl,
fetchFromGitHub,
fetchpatch,
addOpenGLRunpath,
cmake,
fdk_aac,
ffmpeg,
jansson,
libjack2,
libxkbcommon,
libpthreadstubs,
libXdmcp,
qtbase,
qtsvg,
speex,
libv4l,
x264,
curl,
wayland,
xorg,
pkg-config,
libvlc,
libGL,
mbedtls,
wrapGAppsHook3,
scriptingSupport ? true,
luajit,
swig4,
python3,
alsaSupport ? stdenv.isLinux,
alsa-lib,
pulseaudioSupport ? config.pulseaudio or stdenv.isLinux,
libpulseaudio,
libcef,
pciutils,
pipewireSupport ? stdenv.isLinux,
withFdk ? true,
pipewire,
libdrm,
libajantv2,
librist,
libva,
srt,
qtwayland,
wrapQtAppsHook,
nlohmann_json,
websocketpp,
asio,
decklinkSupport ? false,
blackmagic-desktop-video,
libdatachannel,
libvpl,
qrcodegencpp,
nix-update-script,
}:

let
inherit (lib) optional optionals;
libcef_obs = libcef.overrideAttrs (_: {
version = "5060";
src = fetchurl {
url = "https://cdn-fastly.obsproject.com/downloads/cef_binary_5060_linux_x86_64_v3.tar.xz";
hash = "sha256-ElOmo2w7isW17Om/226uardeSVFjdfxHXi6HF5Wtm+o=1";
};
postUnpack = "rm -r */build";
});
in

stdenv.mkDerivation (finalAttrs: {
Expand Down Expand Up @@ -92,55 +102,61 @@ stdenv.mkDerivation (finalAttrs: {
pkg-config
wrapGAppsHook3
wrapQtAppsHook
]
++ optional scriptingSupport swig4;

buildInputs = [
curl
ffmpeg
jansson
libcef
libjack2
libv4l
libxkbcommon
libpthreadstubs
libXdmcp
qtbase
qtsvg
speex
wayland
x264
libvlc
mbedtls
pciutils
libajantv2
librist
libva
srt
qtwayland
nlohmann_json
websocketpp
asio
libdatachannel
libvpl
qrcodegencpp
]
++ optionals scriptingSupport [ luajit python3 ]
++ optional alsaSupport alsa-lib
++ optional pulseaudioSupport libpulseaudio
++ optionals pipewireSupport [ pipewire libdrm ]
++ optional withFdk fdk_aac;
] ++ optional scriptingSupport swig4;

buildInputs =
[
curl
ffmpeg
jansson
libcef_obs
libjack2
libv4l
libxkbcommon
libpthreadstubs
libXdmcp
qtbase
qtsvg
speex
wayland
x264
libvlc
mbedtls
pciutils
libajantv2
librist
libva
srt
qtwayland
nlohmann_json
websocketpp
asio
libdatachannel
libvpl
qrcodegencpp
]
++ optionals scriptingSupport [
luajit
python3
]
++ optional alsaSupport alsa-lib
++ optional pulseaudioSupport libpulseaudio
++ optionals pipewireSupport [
pipewire
libdrm
]
++ optional withFdk fdk_aac;

# Copied from the obs-linuxbrowser
postUnpack = ''
mkdir -p cef/Release cef/Resources cef/libcef_dll_wrapper/
for i in ${libcef}/share/cef/*; do
for i in ${libcef_obs}/share/cef/*; do
ln -s $i cef/Release/
ln -s $i cef/Resources/
done
ln -s ${libcef}/lib/libcef.so cef/Release/
ln -s ${libcef}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/
ln -s ${libcef}/include cef/
ln -s ${libcef_obs}/lib/libcef.so cef/Release/
ln -s ${libcef_obs}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/
ln -s ${libcef_obs}/include cef/
'';

cmakeFlags = [
Expand All @@ -162,30 +178,30 @@ stdenv.mkDerivation (finalAttrs: {
];

dontWrapGApps = true;
preFixup = let
wrapperLibraries = [
xorg.libX11
libvlc
libGL
] ++ optionals decklinkSupport [
blackmagic-desktop-video
];
in ''
# Remove libcef before patchelf, otherwise it will fail
rm $out/lib/obs-plugins/libcef.so

qtWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}"
''${gappsWrapperArgs[@]}
)
'';
preFixup =
let
wrapperLibraries = [
xorg.libX11
libvlc
libGL
] ++ optionals decklinkSupport [ blackmagic-desktop-video ];
in
''
# Remove libcef before patchelf, otherwise it will fail
rm $out/lib/obs-plugins/libcef.so

qtWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}"
''${gappsWrapperArgs[@]}
)
'';

postFixup = lib.optionalString stdenv.isLinux ''
addOpenGLRunpath $out/lib/lib*.so
addOpenGLRunpath $out/lib/obs-plugins/*.so

# Link libcef again after patchelfing other libs
ln -s ${libcef}/lib/* $out/lib/obs-plugins/
ln -s ${libcef_obs}/lib/* $out/lib/obs-plugins/
'';

passthru.updateScript = nix-update-script { };
Expand All @@ -198,9 +214,18 @@ stdenv.mkDerivation (finalAttrs: {
video content, efficiently
'';
homepage = "https://obsproject.com";
maintainers = with maintainers; [ eclairevoyant jb55 materus fpletz ];
maintainers = with maintainers; [
eclairevoyant
jb55
materus
fpletz
];
license = with licenses; [ gpl2Plus ] ++ optional withFdk fraunhofer-fdk;
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
platforms = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The architecture should be changed to only list x86_64-linux because the binary build of CEF provided by upstream is x86_64 only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking this a draft for now. I was searching for binaries for other architectures but wasn't successful. It would be best if our version of CEF would be supported but I'm not sure what's the problem. Using the binary provided by OBS does fix it though.

"x86_64-linux"
"i686-linux"
"aarch64-linux"
];
mainProgram = "obs";
};
})