about summary refs log tree commit diff
path: root/pkgs/applications/video/davinci-resolve
diff options
context:
space:
mode:
authorPeder Bergebakken Sundt <pbsds@hotmail.com>2023-12-02 13:35:43 +0100
committerGitHub <noreply@github.com>2023-12-02 13:35:43 +0100
commit669b964ecfe32f4bff7eb9738ac961cf45f72414 (patch)
tree45cb1f965c8033ed1a293031c667a4d7196e741b /pkgs/applications/video/davinci-resolve
parent6e08bfcf90c79ae266b881933bab4b219e1e5711 (diff)
parentf1361c508956058c5c7de49604cca4769bb45a49 (diff)
Merge pull request #255577 from amarshall/davinci-resolve
davinci-resolve: 18.5.1 -> 18.6.2; add studio variant; various improvements
Diffstat (limited to 'pkgs/applications/video/davinci-resolve')
-rw-r--r--pkgs/applications/video/davinci-resolve/default.nix50
1 files changed, 38 insertions, 12 deletions
diff --git a/pkgs/applications/video/davinci-resolve/default.nix b/pkgs/applications/video/davinci-resolve/default.nix
index 8070a96a2b4b3..5b44ddc042a30 100644
--- a/pkgs/applications/video/davinci-resolve/default.nix
+++ b/pkgs/applications/video/davinci-resolve/default.nix
@@ -22,13 +22,16 @@
 , aprutil
 , makeDesktopItem
 , copyDesktopItems
+, jq
+
+, studioVariant ? false
 }:
 
 let
   davinci = (
     stdenv.mkDerivation rec {
-      pname = "davinci-resolve";
-      version = "18.5.1";
+      pname = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
+      version = "18.6.3";
 
       nativeBuildInputs = [
         (appimage-run.override { buildFHSEnv = buildFHSEnvChroot; } )
@@ -47,19 +50,24 @@ let
         rec {
           outputHashMode = "recursive";
           outputHashAlgo = "sha256";
-          outputHash = "sha256-AZ869hA/WeCf3sxhdDOzD/q30P1NaD18TheBtS1ammQ=";
+          outputHash =
+            if studioVariant
+            then "sha256-OX8PyMhfl0jRdXBNsjlwkCAh8XUNJv8HEbmyAdjIv18="
+            else "sha256-PNzdVxGgXIHM2vi3ChHx67TQBFlCYBOZCiFkDi/RSu4=";
 
           impureEnvVars = lib.fetchers.proxyImpureEnvVars;
 
-          nativeBuildInputs = [ curl ];
+          nativeBuildInputs = [ curl jq ];
 
           # ENV VARS
           SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
 
           # Get linux.downloadId from HTTP response on https://www.blackmagicdesign.com/products/davinciresolve
-          DOWNLOADID = "defc1c6789b7475b9ee4a42daf9ba61d";
           REFERID = "263d62f31cbb49e0868005059abcb0c9";
-          SITEURL = "https://www.blackmagicdesign.com/api/register/us/download/${DOWNLOADID}";
+          DOWNLOADSURL = "https://www.blackmagicdesign.com/api/support/us/downloads.json";
+          SITEURL = "https://www.blackmagicdesign.com/api/register/us/download";
+          PRODUCT = "DaVinci Resolve${lib.optionalString studioVariant " Studio"}";
+          VERSION = version;
 
           USERAGENT = builtins.concatStringsSep " " [
             "User-Agent: Mozilla/5.0 (X11; Linux ${stdenv.hostPlatform.linuxArch})"
@@ -77,10 +85,16 @@ let
             "street" = "Hogeweide 346";
             "state" = "Province of Utrecht";
             "city" = "Utrecht";
-            "product" = "DaVinci Resolve";
+            "product" = PRODUCT;
           };
 
         } ''
+        DOWNLOADID=$(
+          curl --silent --compressed "$DOWNLOADSURL" \
+            | jq --raw-output '.downloads[] | select(.name | test("^'"$PRODUCT $VERSION"'( Update)?$")) | .urls.Linux[0].downloadId'
+        )
+        echo "downloadid is $DOWNLOADID"
+        test -n "$DOWNLOADID"
         RESOLVEURL=$(curl \
           --silent \
           --header 'Host: www.blackmagicdesign.com' \
@@ -95,7 +109,7 @@ let
           --header 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \
           --data-ascii "$REQJSON" \
           --compressed \
-          "$SITEURL")
+          "$SITEURL/$DOWNLOADID")
 
         curl \
           --retry 3 --retry-delay 3 \
@@ -111,14 +125,17 @@ let
       # The unpack phase won't generate a directory
       sourceRoot = ".";
 
-      installPhase = ''
+      installPhase = let
+        appimageName = "DaVinci_Resolve_${lib.optionalString studioVariant "Studio_"}${version}_Linux.run";
+      in ''
         runHook preInstall
 
         export HOME=$PWD/home
         mkdir -p $HOME
 
         mkdir -p $out
-        appimage-run ./DaVinci_Resolve_${version}_Linux.run -i -y -n -C $out
+        test -e ${lib.escapeShellArg appimageName}
+        appimage-run ${lib.escapeShellArg appimageName} -i -y -n -C $out
 
         mkdir -p $out/{configs,DolbyVision,easyDCP,Fairlight,GPUCache,logs,Media,"Resolve Disk Database",.crashreport,.license,.LUT}
         runHook postInstall
@@ -162,7 +179,9 @@ let
   );
 in
 buildFHSEnv {
-  name = "davinci-resolve";
+  inherit (davinci) pname version;
+  name = null;
+
   targetPkgs = pkgs: with pkgs; [
     alsa-lib
     aprutil
@@ -201,6 +220,7 @@ buildFHSEnv {
     xorg.libXinerama
     xorg.libXrandr
     xorg.libXrender
+    xorg.libXt
     xorg.libXtst
     xorg.libXxf86vm
     xorg.libxcb
@@ -213,16 +233,22 @@ buildFHSEnv {
     zlib
   ];
 
+  extraBwrapArgs = lib.optionals studioVariant [
+    "--bind \"$HOME\"/.local/share/DaVinciResolve/license ${davinci}/.license"
+  ];
+
   runScript = "${bash}/bin/bash ${
     writeText "davinci-wrapper"
     ''
     export QT_XKB_CONFIG_ROOT="${xkeyboard_config}/share/X11/xkb"
     export QT_PLUGIN_PATH="${davinci}/libs/plugins:$QT_PLUGIN_PATH"
-    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${davinci}/libs
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib32:${davinci}/libs
     ${davinci}/bin/resolve
     ''
   }";
 
+  passthru = { inherit davinci; };
+
   meta = with lib; {
     description = "Professional video editing, color, effects and audio post-processing";
     homepage = "https://www.blackmagicdesign.com/products/davinciresolve";