From 48947b5d96c9f440bd0ea95baa7fd48bfa55ff16 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 21 Dec 2024 01:02:10 +0000 Subject: [PATCH 1/5] obs-studio: port to new build system They would like builders to use CMake presets now; we inherit from their Ubuntu and macOS presets respectively. --- .../video/obs-studio/CMakeUserPresets.json | 17 +++++++++++++ .../applications/video/obs-studio/default.nix | 25 ++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 pkgs/applications/video/obs-studio/CMakeUserPresets.json 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..447af0b9b803 100644 --- a/pkgs/applications/video/obs-studio/default.nix +++ b/pkgs/applications/video/obs-studio/default.nix @@ -2,6 +2,7 @@ , uthash , lib , stdenv +, ninja , nv-codec-headers-12 , fetchFromGitHub , fetchpatch @@ -42,6 +43,7 @@ , pipewire , libdrm , librist +, cjson , libva , srt , qtwayland @@ -107,6 +109,7 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ addDriverRunpath cmake + ninja pkg-config wrapGAppsHook3 wrapQtAppsHook @@ -132,6 +135,7 @@ stdenv.mkDerivation (finalAttrs: { mbedtls pciutils librist + cjson libva srt qtwayland @@ -157,18 +161,25 @@ stdenv.mkDerivation (finalAttrs: { 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" + "-DENABLE_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) @@ -193,8 +204,13 @@ stdenv.mkDerivation (finalAttrs: { blackmagic-desktop-video ]; in '' - # Remove libcef before patchelf, otherwise it will fail + # 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}" @@ -206,8 +222,9 @@ stdenv.mkDerivation (finalAttrs: { addDriverRunpath $out/lib/lib*.so addDriverRunpath $out/lib/obs-plugins/*.so - # Link libcef again after patchelfing other libs + # 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 { }; From 1f6fe98d1e545861c178475b7ad91d69757c49a1 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sun, 29 Dec 2024 17:37:25 +0000 Subject: [PATCH 2/5] obs-studio: 30.2.3 -> 31.0.1 --- .../applications/video/obs-studio/default.nix | 27 ++----------------- .../obs-studio/fix-nix-plugin-path.patch | 13 --------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/pkgs/applications/video/obs-studio/default.nix b/pkgs/applications/video/obs-studio/default.nix index 447af0b9b803..02ebf38f611f 100644 --- a/pkgs/applications/video/obs-studio/default.nix +++ b/pkgs/applications/video/obs-studio/default.nix @@ -65,13 +65,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; }; @@ -81,29 +81,6 @@ 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 = [ 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 From a99cff7ebab55d7ea2547e59350c0c6312d4c6fa Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Mon, 30 Dec 2024 02:59:17 +0100 Subject: [PATCH 3/5] obs-studio-plugins.wlrobs: 2023-08-23 -> 2024-12-24 --- pkgs/applications/video/obs-studio/plugins/wlrobs.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 = [ From 5592fc0a126887f258a45aa70774866587aec1c0 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Thu, 13 Feb 2025 15:55:17 +0100 Subject: [PATCH 4/5] obs-studio: reformat --- .../applications/video/obs-studio/default.nix | 263 ++++++++++-------- 1 file changed, 141 insertions(+), 122 deletions(-) diff --git a/pkgs/applications/video/obs-studio/default.nix b/pkgs/applications/video/obs-studio/default.nix index 02ebf38f611f..99cb6da36458 100644 --- a/pkgs/applications/video/obs-studio/default.nix +++ b/pkgs/applications/video/obs-studio/default.nix @@ -1,62 +1,62 @@ -{ config -, uthash -, lib -, stdenv -, ninja -, 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 -, cjson -, 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, + 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 @@ -90,46 +90,52 @@ stdenv.mkDerivation (finalAttrs: { 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 - 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 withFdk fdk_aac; + buildInputs = + [ + curl + ffmpeg + jansson + libcef + 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 withFdk fdk_aac; # Copied from the obs-linuxbrowser postUnpack = '' @@ -149,7 +155,8 @@ stdenv.mkDerivation (finalAttrs: { ''; cmakeFlags = [ - "--preset" "nixpkgs-${if stdenv.hostPlatform.isDarwin then "darwin" else "linux"}" + "--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 @@ -172,28 +179,32 @@ stdenv.mkDerivation (finalAttrs: { ]; dontWrapGApps = true; - preFixup = let - wrapperLibraries = [ - xorg.libX11 - libvlc - libGL - ] ++ optionals decklinkSupport [ - blackmagic-desktop-video - ]; - in '' - # 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 + preFixup = + let + wrapperLibraries = + [ + xorg.libX11 + libvlc + libGL + ] + ++ optionals decklinkSupport [ + blackmagic-desktop-video + ]; + in + '' + # 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[@]} - ) - ''; + qtWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}" + ''${gappsWrapperArgs[@]} + ) + ''; postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' addDriverRunpath $out/lib/lib*.so @@ -214,9 +225,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"; }; }) From 74b7941a4645cab57deb70fee3e5c31e7d7a7c22 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Thu, 13 Feb 2025 16:00:25 +0100 Subject: [PATCH 5/5] obs-studio: make browser support optional --- .../applications/video/obs-studio/default.nix | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/pkgs/applications/video/obs-studio/default.nix b/pkgs/applications/video/obs-studio/default.nix index 99cb6da36458..f4e19bd370ff 100644 --- a/pkgs/applications/video/obs-studio/default.nix +++ b/pkgs/applications/video/obs-studio/default.nix @@ -36,6 +36,7 @@ alsa-lib, pulseaudioSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux, libpulseaudio, + browserSupport ? false, # FIXME: broken libcef, pciutils, pipewireSupport ? stdenv.hostPlatform.isLinux, @@ -97,7 +98,6 @@ stdenv.mkDerivation (finalAttrs: { curl ffmpeg jansson - libcef libjack2 libv4l libxkbcommon @@ -135,10 +135,11 @@ stdenv.mkDerivation (finalAttrs: { 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/ @@ -159,9 +160,6 @@ stdenv.mkDerivation (finalAttrs: { "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 - "-DENABLE_BROWSER=ON" - "-DCEF_ROOT_DIR=../../cef" "-DENABLE_JACK=ON" "-DENABLE_WEBRTC=ON" (lib.cmakeBool "ENABLE_QSV11" stdenv.hostPlatform.isx86_64) @@ -170,7 +168,8 @@ stdenv.mkDerivation (finalAttrs: { (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" @@ -192,6 +191,12 @@ stdenv.mkDerivation (finalAttrs: { ]; 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 @@ -199,21 +204,20 @@ stdenv.mkDerivation (finalAttrs: { 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.optionalString stdenv.hostPlatform.isLinux '' - addDriverRunpath $out/lib/lib*.so - addDriverRunpath $out/lib/obs-plugins/*.so + postFixup = lib.concatStrings [ + (lib.optionalString stdenv.hostPlatform.isLinux '' + addDriverRunpath $out/lib/lib*.so + addDriverRunpath $out/lib/obs-plugins/*.so + '') - # 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/ - ''; + (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 { };