about summary refs log tree commit diff
path: root/pkgs/applications/video/davinci-resolve
diff options
context:
space:
mode:
authorJoshua Campbell <me@joshuadcampbell.com>2024-02-25 17:57:18 -0800
committerJoshua Campbell <me@joshuadcampbell.com>2024-05-04 20:15:46 -0700
commite11b9dd5fda5cffc1b0b73ee993df798ac264775 (patch)
treeee4c959b5459e65c0e16c1ad4156cf75b4a0ada7 /pkgs/applications/video/davinci-resolve
parent4b164e2b03ceb279994202550a78b292a933ccf1 (diff)
davinci-resolve: add updateScript
Diffstat (limited to 'pkgs/applications/video/davinci-resolve')
-rw-r--r--pkgs/applications/video/davinci-resolve/default.nix26
1 files changed, 25 insertions, 1 deletions
diff --git a/pkgs/applications/video/davinci-resolve/default.nix b/pkgs/applications/video/davinci-resolve/default.nix
index bb631909872cf..bca8bc1e48ed2 100644
--- a/pkgs/applications/video/davinci-resolve/default.nix
+++ b/pkgs/applications/video/davinci-resolve/default.nix
@@ -25,6 +25,9 @@
 , jq
 
 , studioVariant ? false
+
+, common-updater-scripts
+, writeShellApplication
 }:
 
 let
@@ -251,7 +254,28 @@ buildFHSEnv {
     ''
   }";
 
-  passthru = { inherit davinci; };
+  passthru = {
+    inherit davinci;
+    updateScript = lib.getExe (writeShellApplication {
+      name = "update-davinci-resolve";
+      runtimeInputs = [ curl jq common-updater-scripts ];
+      text = ''
+        set -o errexit
+        drv=pkgs/applications/video/davinci-resolve/default.nix
+        currentVersion=${lib.escapeShellArg davinci.version}
+        downloadsJSON="$(curl --fail --silent https://www.blackmagicdesign.com/api/support/us/downloads.json)"
+
+        latestLinuxVersion="$(echo "$downloadsJSON" | jq '[.downloads[] | select(.urls.Linux) | .urls.Linux[] | select(.downloadTitle | test("DaVinci Resolve")) | .downloadTitle]' | grep -oP 'DaVinci Resolve \K\d+\.\d+\.\d+' | sort | tail -n 1)"
+        update-source-version davinci-resolve "$latestLinuxVersion" --source-key=davinci.src
+
+        # Since the standard and studio both use the same version we need to reset it before updating studio
+        sed -i -e "s/""$latestLinuxVersion""/""$currentVersion""/" "$drv"
+
+        latestStudioLinuxVersion="$(echo "$downloadsJSON" | jq '[.downloads[] | select(.urls.Linux) | .urls.Linux[] | select(.downloadTitle | test("DaVinci Resolve")) | .downloadTitle]' | grep -oP 'DaVinci Resolve Studio \K\d+\.\d+\.\d+' | sort | tail -n 1)"
+        update-source-version davinci-resolve-studio "$latestStudioLinuxVersion" --source-key=davinci.src
+      '';
+    });
+  };
 
   meta = with lib; {
     description = "Professional video editing, color, effects and audio post-processing";