From c95664665d15ccbf4a490c3db7c07b00925788a1 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Mon, 18 Nov 2019 10:15:52 +0100 Subject: [PATCH] obs-studio: package the missing ndi library to make the obs-ndi plug-in actually work --- .../video/obs-studio/hardcode-ndi-path.patch | 17 ++++++ .../applications/video/obs-studio/obs-ndi.nix | 14 +++-- pkgs/development/libraries/ndi/default.nix | 60 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 pkgs/applications/video/obs-studio/hardcode-ndi-path.patch create mode 100644 pkgs/development/libraries/ndi/default.nix diff --git a/pkgs/applications/video/obs-studio/hardcode-ndi-path.patch b/pkgs/applications/video/obs-studio/hardcode-ndi-path.patch new file mode 100644 index 000000000000..caef96c381f2 --- /dev/null +++ b/pkgs/applications/video/obs-studio/hardcode-ndi-path.patch @@ -0,0 +1,17 @@ +diff --git a/src/obs-ndi.cpp b/src/obs-ndi.cpp +index 493831c..7b0f8db 100644 +--- a/src/obs-ndi.cpp ++++ b/src/obs-ndi.cpp +@@ -197,11 +197,7 @@ const char* obs_module_description() + const NDIlib_v4* load_ndilib() + { + QStringList locations; +- locations << QString(qgetenv(NDILIB_REDIST_FOLDER)); +-#if defined(__linux__) || defined(__APPLE__) +- locations << "/usr/lib"; +- locations << "/usr/local/lib"; +-#endif ++ locations << "@NDI@/lib"; + + for (QString path : locations) { + blog(LOG_INFO, "Trying '%s'", path.toUtf8().constData()); diff --git a/pkgs/applications/video/obs-studio/obs-ndi.nix b/pkgs/applications/video/obs-studio/obs-ndi.nix index 450ebf4ac20d..452793f442ee 100644 --- a/pkgs/applications/video/obs-studio/obs-ndi.nix +++ b/pkgs/applications/video/obs-studio/obs-ndi.nix @@ -2,15 +2,18 @@ # somewhat manually install this: # nix-env -f "" -iA obs-ndi -# mkdir -p ~/.config/obs-studio/plugins -# ln -s ~/.nix-profile/share/obs/obs-plugins/obs-ndi ~/.config/obs-studio/plugins/ +# mkdir -p ~/.config/obs-studio/plugins/bin +# ln -s ~/.nix-profile/lib/obs-plugins/obs-ndi.so ~/.config/obs-studio/plugins/bin/ -{ stdenv, fetchFromGitHub, obs-studio, cmake, qt5 }: +{ stdenv, fetchFromGitHub, obs-studio, cmake, qt5, ndi }: stdenv.mkDerivation rec { pname = "obs-ndi"; version = "4.7.1"; + nativeBuildInputs = [ cmake ]; + buildInputs = [ obs-studio qt5.qtbase ndi ]; + src = fetchFromGitHub { owner = "Palakis"; repo = "obs-ndi"; @@ -18,10 +21,9 @@ stdenv.mkDerivation rec { sha256 = "040fkbf3f3qgqcrd3072y3zrjb4fwga8zr10jym744xd7bgyylqh"; }; - patches = [ ./fix-search-path.patch ]; + patches = [ ./fix-search-path.patch ./hardcode-ndi-path.patch ]; - nativeBuildInputs = [ cmake ]; - buildInputs = [ obs-studio qt5.qtbase ]; + postPatch = "sed -i -e s,@NDI@,${ndi},g src/obs-ndi.cpp"; cmakeFlags = [ "-DLIBOBS_INCLUDE_DIR=${obs-studio}/include/obs" diff --git a/pkgs/development/libraries/ndi/default.nix b/pkgs/development/libraries/ndi/default.nix new file mode 100644 index 000000000000..fcf9457c691c --- /dev/null +++ b/pkgs/development/libraries/ndi/default.nix @@ -0,0 +1,60 @@ +{ stdenv, requireFile, avahi }: + +stdenv.mkDerivation rec { + pname = "ndi"; + version = "4"; + + src = requireFile rec { + name = "InstallNDISDK_v${version}_Linux.tar.gz"; + sha256 = "1hac5npyg8nifs9ipj34pkn0zjyx8774x3i3h8znhmijx2j2982p"; + message = '' + In order to use the NDI SDK, you need to comply with NewTek's license and + download the Linux version ${version} tarball from: + + ${meta.homepage} + + Once you have downloaded the file, please use the following command and + re-run the installation: + + nix-prefetch-url file://\$PWD/${name} + ''; + }; + + buildInputs = [ avahi ]; + + unpackPhase = '' + unpackFile ${src} + echo y | ./InstallNDISDK_v4_Linux.sh + sourceRoot="NDI SDK for Linux"; + ''; + + installPhase = '' + mkdir $out + mv bin/x86_64-linux-gnu $out/bin + for i in $out/bin/*; do + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$i" + done + patchelf --set-rpath "${avahi}/lib:${stdenv.cc.libc}/lib" $out/bin/ndi-record + mv lib/x86_64-linux-gnu $out/lib + for i in $out/lib/*; do + if [ -L "$i" ]; then continue; fi + patchelf --set-rpath "${avahi}/lib:${stdenv.cc.libc}/lib" "$i" + done + mv include examples $out/ + mkdir -p $out/share/doc/${pname}-${version} + mv licenses $out/share/doc/${pname}-${version}/licenses + mv logos $out/share/doc/${pname}-${version}/logos + mv documentation/* $out/share/doc/${pname}-${version}/ + ''; + + # Stripping breaks ndi-record. + dontStrip = true; + + meta = with stdenv.lib; { + homepage = "https://ndi.tv/sdk/"; + description = "NDI Software Developer Kit"; + platforms = ["x86_64-linux"]; + hydraPlatforms = []; + license = licenses.unfree; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a401c5b4fb84..89e15ed63e11 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13181,6 +13181,8 @@ in then null else callPackage ../development/libraries/ncurses { }; + ndi = callPackage ../development/libraries/ndi { }; + neardal = callPackage ../development/libraries/neardal { }; neon = callPackage ../development/libraries/neon { };