diff --git a/pkgs/os-specific/linux/decklink/default.nix b/pkgs/os-specific/linux/decklink/default.nix index 8d0d167bc7f5..63bfe4a63af2 100644 --- a/pkgs/os-specific/linux/decklink/default.nix +++ b/pkgs/os-specific/linux/decklink/default.nix @@ -1,14 +1,16 @@ -{ stdenv, lib, requireFile, fetchpatch, kernel }: +{ stdenv +, lib +, blackmagic-desktop-video +, kernel +}: stdenv.mkDerivation rec { pname = "decklink"; - version = "12.2a12"; - src = requireFile { - name = "Blackmagic_Desktop_Video_Linux_${lib.versions.majorMinor version}.tar.gz"; - url = "https://www.blackmagicdesign.com/support/download/33abc1034cd54cf99101f9acd2edd93d/Linux"; - sha256 = "62954a18b60d9040aa4a959dff30ac9c260218ef78d6a63cbb243788f7abc05f"; - }; + # the download is a horrible curl mess. we reuse it between the kernel module + # and desktop service, since the version of the two have to match anyways. + # See pkgs/tools/video/blackmagic-desktop-video/default.nix for more. + inherit (blackmagic-desktop-video) src version; KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; INSTALL_MOD_PATH = placeholder "out"; diff --git a/pkgs/tools/video/blackmagic-desktop-video/default.nix b/pkgs/tools/video/blackmagic-desktop-video/default.nix index 48e16d3b94b6..dc6f2eff7873 100644 --- a/pkgs/tools/video/blackmagic-desktop-video/default.nix +++ b/pkgs/tools/video/blackmagic-desktop-video/default.nix @@ -1,20 +1,78 @@ -{ stdenv, requireFile, lib, - libcxx, libcxxabi +{ stdenv +, cacert +, curl +, runCommandLocal +, lib +, autoPatchelfHook +, libcxx +, libcxxabi +, libGL +, gcc7 }: stdenv.mkDerivation rec { pname = "blackmagic-desktop-video"; - version = "12.2a12"; + version = "12.5a15"; buildInputs = [ - libcxx libcxxabi + autoPatchelfHook + libcxx + libcxxabi + libGL + gcc7.cc.lib ]; - src = requireFile { - name = "Blackmagic_Desktop_Video_Linux_${lib.versions.majorMinor version}.tar.gz"; - url = "https://www.blackmagicdesign.com/support/download/33abc1034cd54cf99101f9acd2edd93d/Linux"; - sha256 = "62954a18b60d9040aa4a959dff30ac9c260218ef78d6a63cbb243788f7abc05f"; - }; + # yes, the below download function is an absolute mess. + # blame blackmagicdesign. + src = runCommandLocal "${pname}-${lib.versions.majorMinor version}-src.tar.gz" + rec { + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + outputHash = "sha256-ss7Ab5dy7cmXp9LBirFXMeGY4ZbYHvWnXmYvNeBq0RY="; + + impureEnvVars = lib.fetchers.proxyImpureEnvVars; + + nativeBuildInputs = [ curl ]; + + # ENV VARS + SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + + # from the URL that the POST happens to, see browser console + DOWNLOADID = "fecacc0f9b2f4c2e8bf2863e9e26c8e1"; + # from the URL the download page where you click the "only download" button is at + REFERID = "052d944af6744608b27da496dfc4396d"; + SITEURL = "https://www.blackmagicdesign.com/api/register/us/download/${DOWNLOADID}"; + + USERAGENT = builtins.concatStringsSep " " [ + "User-Agent: Mozilla/5.0 (X11; Linux ${stdenv.targetPlatform.linuxArch})" + "AppleWebKit/537.36 (KHTML, like Gecko)" + "Chrome/77.0.3865.75" + "Safari/537.36" + ]; + + REQJSON = builtins.toJSON { + "country" = "nl"; + "downloadOnly" = true; + "platform" = "Linux"; + "policy" = true; + }; + + } '' + RESOLVEURL=$(curl \ + -s \ + -H "$USERAGENT" \ + -H 'Content-Type: application/json;charset=UTF-8' \ + -H "Referer: https://www.blackmagicdesign.com/support/download/$REFERID/Linux" \ + --data-ascii "$REQJSON" \ + --compressed \ + "$SITEURL") + + curl \ + --retry 3 --retry-delay 3 \ + --compressed \ + "$RESOLVEURL" \ + > $out + ''; postUnpack = '' tar xf Blackmagic_Desktop_Video_Linux_${lib.versions.majorMinor version}/other/${stdenv.hostPlatform.uname.processor}/desktopvideo-${version}-${stdenv.hostPlatform.uname.processor}.tar.gz @@ -28,8 +86,6 @@ stdenv.mkDerivation rec { cp -r $unpacked/usr/share/doc/desktopvideo $out/share/doc cp $unpacked/usr/lib/*.so $out/lib cp $unpacked/usr/lib/systemd/system/DesktopVideoHelper.service $out/lib/systemd/system - ln -s ${libcxx}/lib/* ${libcxxabi}/lib/* $out/lib - cp $unpacked/usr/lib/blackmagic/DesktopVideo/libgcc_s.so.1 $out/lib/ cp $unpacked/usr/lib/blackmagic/DesktopVideo/DesktopVideoHelper $out/bin/ substituteInPlace $out/lib/systemd/system/DesktopVideoHelper.service --replace "/usr/lib/blackmagic/DesktopVideo/DesktopVideoHelper" "$out/bin/DesktopVideoHelper" @@ -37,12 +93,8 @@ stdenv.mkDerivation rec { runHook postInstall ''; - - postFixup = '' - patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \ - --set-rpath "$out/lib:${lib.makeLibraryPath [ libcxx libcxxabi ]}" \ - $out/bin/DesktopVideoHelper - ''; + # i know this is ugly, but it's the cleanest way i found to tell the DesktopVideoHelper where to find its own library + appendRunpaths = [ "$ORIGIN/../lib" ]; meta = with lib; { homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback";