diff --git a/pkgs/applications/video/obs-studio/CMakeUserPresets.json b/pkgs/applications/video/obs-studio/CMakeUserPresets.json new file mode 100644 index 000000000000..932ca674c09e --- /dev/null +++ b/pkgs/applications/video/obs-studio/CMakeUserPresets.json @@ -0,0 +1,17 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "nixpkgs-linux", + "displayName": "Nixpkgs (Linux)", + "inherits": ["ubuntu"], + "binaryDir": "${sourceDir}/build" + }, + { + "name": "nixpkgs-darwin", + "displayName": "Nixpkgs (Darwin)", + "inherits": ["macos"], + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/pkgs/applications/video/obs-studio/default.nix b/pkgs/applications/video/obs-studio/default.nix index 5dff164084de..f4e19bd370ff 100644 --- a/pkgs/applications/video/obs-studio/default.nix +++ b/pkgs/applications/video/obs-studio/default.nix @@ -1,60 +1,63 @@ -{ config -, uthash -, lib -, stdenv -, nv-codec-headers-12 -, fetchFromGitHub -, fetchpatch -, addDriverRunpath -, 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 -, swig -, python3 -, alsaSupport ? stdenv.hostPlatform.isLinux -, alsa-lib -, pulseaudioSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux -, libpulseaudio -, libcef -, pciutils -, pipewireSupport ? stdenv.hostPlatform.isLinux -, withFdk ? true -, pipewire -, libdrm -, librist -, libva -, srt -, qtwayland -, wrapQtAppsHook -, nlohmann_json -, websocketpp -, asio -, decklinkSupport ? false -, blackmagic-desktop-video -, libdatachannel -, libvpl -, qrcodegencpp -, nix-update-script +{ + config, + uthash, + lib, + stdenv, + ninja, + nv-codec-headers-12, + fetchFromGitHub, + addDriverRunpath, + 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, + swig, + python3, + alsaSupport ? stdenv.hostPlatform.isLinux, + alsa-lib, + pulseaudioSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux, + libpulseaudio, + browserSupport ? false, # FIXME: broken + libcef, + pciutils, + pipewireSupport ? stdenv.hostPlatform.isLinux, + withFdk ? true, + pipewire, + libdrm, + librist, + cjson, + libva, + srt, + qtwayland, + wrapQtAppsHook, + nlohmann_json, + websocketpp, + asio, + decklinkSupport ? false, + blackmagic-desktop-video, + libdatachannel, + libvpl, + qrcodegencpp, + nix-update-script, }: let @@ -63,13 +66,13 @@ in stdenv.mkDerivation (finalAttrs: { pname = "obs-studio"; - version = "30.2.3"; + version = "31.0.1"; src = fetchFromGitHub { owner = "obsproject"; repo = "obs-studio"; rev = finalAttrs.version; - hash = "sha256-4bAzW62xX9apKOAJyn3iys1bFdHj4re2reMZtlGsn5s="; + hash = "sha256-dwS/90j4WfcneAsGFwuABM7xqvq1+VSD2uDVdU/GgQo="; fetchSubmodules = true; }; @@ -79,103 +82,94 @@ stdenv.mkDerivation (finalAttrs: { # Lets obs-browser build against CEF 90.1.0+ ./Enable-file-access-and-universal-access-for-file-URL.patch ./fix-nix-plugin-path.patch - - # Fix libobs.pc for plugins on non-x86 systems - (fetchpatch { - name = "fix-arm64-cmake.patch"; - url = "https://git.alpinelinux.org/aports/plain/community/obs-studio/broken-config.patch?id=a92887564dcc65e07b6be8a6224fda730259ae2b"; - hash = "sha256-yRSw4VWDwMwysDB3Hw/tsmTjEQUhipvrVRQcZkbtuoI="; - includes = [ "*/CompilerConfig.cmake" ]; - }) - - (fetchpatch { - name = "qt-6.8.patch"; - url = "https://github.com/obsproject/obs-websocket/commit/d9befb9e0a4898695eef5ccbc91a4fac02027854.patch"; - extraPrefix = "plugins/obs-websocket/"; - stripLen = 1; - hash = "sha256-7SDBRr9G40b9DfbgdaYJxTeiDSLUfVixtMtM3cLTVZs="; - }) - - # Fix lossless audio, ffmpeg 7,1 compatibility issue - (fetchpatch { - name = "fix-lossless-audio.patch"; - url = "https://github.com/obsproject/obs-studio/commit/dfc3a69c5276edf84c933035ff2a7e278fa13c9a.patch"; - hash = "sha256-wiF3nolBpZKp7LR7NloNfJ+v4Uq/nBgwCVoKZX+VEMA="; - }) ]; nativeBuildInputs = [ addDriverRunpath cmake + ninja pkg-config wrapGAppsHook3 wrapQtAppsHook - ] - ++ optional scriptingSupport swig; + ] ++ optional scriptingSupport swig; - buildInputs = [ - curl - ffmpeg - jansson - libcef - libjack2 - libv4l - libxkbcommon - libpthreadstubs - libXdmcp - qtbase - qtsvg - speex - wayland - x264 - libvlc - mbedtls - pciutils - librist - libva - srt - qtwayland - nlohmann_json - websocketpp - asio - libdatachannel - libvpl - qrcodegencpp - uthash - nv-codec-headers-12 - ] - ++ optionals scriptingSupport [ luajit python3 ] - ++ optional alsaSupport alsa-lib - ++ optional pulseaudioSupport libpulseaudio - ++ optionals pipewireSupport [ pipewire libdrm ] - ++ optional withFdk fdk_aac; + buildInputs = + [ + curl + ffmpeg + jansson + libjack2 + libv4l + libxkbcommon + libpthreadstubs + libXdmcp + qtbase + qtsvg + speex + wayland + x264 + libvlc + mbedtls + pciutils + librist + cjson + libva + srt + qtwayland + nlohmann_json + websocketpp + asio + libdatachannel + libvpl + qrcodegencpp + uthash + nv-codec-headers-12 + ] + ++ optionals scriptingSupport [ + luajit + python3 + ] + ++ optional alsaSupport alsa-lib + ++ optional pulseaudioSupport libpulseaudio + ++ optionals pipewireSupport [ + pipewire + libdrm + ] + ++ optional browserSupport libcef + ++ optional withFdk fdk_aac; # Copied from the obs-linuxbrowser - postUnpack = '' + postUnpack = lib.optionalString browserSupport '' mkdir -p cef/Release cef/Resources cef/libcef_dll_wrapper/ for i in ${libcef}/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/*.so* cef/Release/ + ln -s ${libcef}/libexec/cef/chrome-sandbox cef/Release/ ln -s ${libcef}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/ ln -s ${libcef}/include cef/ ''; + postPatch = '' + cp ${./CMakeUserPresets.json} ./CMakeUserPresets.json + ''; + cmakeFlags = [ + "--preset" + "nixpkgs-${if stdenv.hostPlatform.isDarwin then "darwin" else "linux"}" "-DOBS_VERSION_OVERRIDE=${finalAttrs.version}" "-Wno-dev" # kill dev warnings that are useless for packaging - # Add support for browser source - "-DBUILD_BROWSER=ON" - "-DCEF_ROOT_DIR=../../cef" "-DENABLE_JACK=ON" + "-DENABLE_WEBRTC=ON" (lib.cmakeBool "ENABLE_QSV11" stdenv.hostPlatform.isx86_64) (lib.cmakeBool "ENABLE_LIBFDK" withFdk) (lib.cmakeBool "ENABLE_ALSA" alsaSupport) (lib.cmakeBool "ENABLE_PULSEAUDIO" pulseaudioSupport) (lib.cmakeBool "ENABLE_PIPEWIRE" pipewireSupport) (lib.cmakeBool "ENABLE_AJA" false) # TODO: fix linking against libajantv2 - ]; + (lib.cmakeBool "ENABLE_BROWSER" browserSupport) + ] ++ lib.optional browserSupport "-DCEF_ROOT_DIR=../../cef"; env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=deprecated-declarations" @@ -184,31 +178,46 @@ 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 + preFixup = + let + wrapperLibraries = + [ + xorg.libX11 + libvlc + libGL + ] + ++ optionals decklinkSupport [ + blackmagic-desktop-video + ]; + in + '' + qtWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}" + ''${gappsWrapperArgs[@]} + ) + '' + + lib.optionalString browserSupport '' + # Remove cef components before patchelf, otherwise it will fail + rm $out/lib/obs-plugins/libcef.so + rm $out/lib/obs-plugins/libEGL.so + rm $out/lib/obs-plugins/libGLESv2.so + rm $out/lib/obs-plugins/libvk_swiftshader.so + rm $out/lib/obs-plugins/libvulkan.so.1 + rm $out/lib/obs-plugins/chrome-sandbox + ''; - qtWrapperArgs+=( - --prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}" - ''${gappsWrapperArgs[@]} - ) - ''; + postFixup = lib.concatStrings [ + (lib.optionalString stdenv.hostPlatform.isLinux '' + addDriverRunpath $out/lib/lib*.so + addDriverRunpath $out/lib/obs-plugins/*.so + '') - postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' - addDriverRunpath $out/lib/lib*.so - addDriverRunpath $out/lib/obs-plugins/*.so - - # Link libcef again after patchelfing other libs - ln -s ${libcef}/lib/* $out/lib/obs-plugins/ - ''; + (lib.optionalString browserSupport '' + # Link cef components again after patchelfing other libs + ln -s ${libcef}/lib/* $out/lib/obs-plugins/ + ln -s ${libcef}/libexec/cef/* $out/lib/obs-plugins/ + '') + ]; passthru.updateScript = nix-update-script { }; @@ -220,9 +229,17 @@ stdenv.mkDerivation (finalAttrs: { video content, efficiently ''; homepage = "https://obsproject.com"; - maintainers = with maintainers; [ jb55 materus fpletz ]; + maintainers = with maintainers; [ + jb55 + materus + fpletz + ]; license = with licenses; [ gpl2Plus ] ++ optional withFdk fraunhofer-fdk; - platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; + platforms = [ + "x86_64-linux" + "i686-linux" + "aarch64-linux" + ]; mainProgram = "obs"; }; }) diff --git a/pkgs/applications/video/obs-studio/fix-nix-plugin-path.patch b/pkgs/applications/video/obs-studio/fix-nix-plugin-path.patch index 13569e8499b5..68d030fe5108 100644 --- a/pkgs/applications/video/obs-studio/fix-nix-plugin-path.patch +++ b/pkgs/applications/video/obs-studio/fix-nix-plugin-path.patch @@ -1,16 +1,3 @@ -diff --git a/cmake/Modules/ObsDefaults_Linux.cmake b/cmake/Modules/ObsDefaults_Linux.cmake -index fe8d72364..1c590fcdb 100644 ---- a/cmake/Modules/ObsDefaults_Linux.cmake -+++ b/cmake/Modules/ObsDefaults_Linux.cmake -@@ -76,7 +76,7 @@ macro(setup_obs_project) - set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}") - -- set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${OBS_SCRIPT_PLUGIN_DESTINATION}") -+ set(OBS_SCRIPT_PLUGIN_PATH "${OBS_SCRIPT_PLUGIN_DESTINATION}") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OBS_LIBRARY_DESTINATION}") - else() - set(OBS_EXECUTABLE_DESTINATION "bin/${_ARCH_SUFFIX}bit") diff --git a/libobs/obs-nix.c b/libobs/obs-nix.c index 77c36be5e..fe8a04813 100644 --- a/libobs/obs-nix.c diff --git a/pkgs/applications/video/obs-studio/plugins/wlrobs.nix b/pkgs/applications/video/obs-studio/plugins/wlrobs.nix index 37950307d9e8..48c6f588308b 100644 --- a/pkgs/applications/video/obs-studio/plugins/wlrobs.nix +++ b/pkgs/applications/video/obs-studio/plugins/wlrobs.nix @@ -12,14 +12,14 @@ stdenv.mkDerivation { pname = "wlrobs"; - version = "unstable-2023-08-23"; + version = "unstable-2024-12-24"; src = fetchFromSourcehut { vc = "hg"; owner = "~scoopta"; repo = "wlrobs"; - rev = "f72d5cb3cbbd3983ae6cfd86cb1940be7372681c"; - hash = "sha256-hiM0d38SSUqbyisP3fAtKRLBDjVKZdU2U1xyXci7yNk="; + rev = "b8668b4d6d6d33e3de86ce3fa4331249bc0abc8b"; + hash = "sha256-gqGnDrfID5hTcpX3EkSGg4yDwa/ZKCQCqJ3feq44I1I="; }; nativeBuildInputs = [