27 , studioVariant ? false
29 , common-updater-scripts
30 , writeShellApplication
35 stdenv.mkDerivation rec {
36 pname = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
40 (appimage-run.override { buildFHSEnv = buildFHSEnvChroot; } )
46 # Pretty sure, there are missing dependencies ...
52 src = runCommandLocal "${pname}-src.zip"
54 outputHashMode = "recursive";
55 outputHashAlgo = "sha256";
58 then "sha256-q11stWFWRDUebAUzGH23R3Spd3EdDG85+6yB/srYCJY="
59 else "sha256-dYTrO0wpIN68WhBovmYLK5uWOQ1nubpSyKqPCDMPMiM=";
61 impureEnvVars = lib.fetchers.proxyImpureEnvVars;
63 nativeBuildInputs = [ curl jq ];
66 SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
68 # Get linux.downloadId from HTTP response on https://www.blackmagicdesign.com/products/davinciresolve
69 REFERID = "263d62f31cbb49e0868005059abcb0c9";
70 DOWNLOADSURL = "https://www.blackmagicdesign.com/api/support/us/downloads.json";
71 SITEURL = "https://www.blackmagicdesign.com/api/register/us/download";
72 PRODUCT = "DaVinci Resolve${lib.optionalString studioVariant " Studio"}";
75 USERAGENT = builtins.concatStringsSep " " [
76 "User-Agent: Mozilla/5.0 (X11; Linux ${stdenv.hostPlatform.linuxArch})"
77 "AppleWebKit/537.36 (KHTML, like Gecko)"
82 REQJSON = builtins.toJSON {
83 "firstname" = "NixOS";
85 "email" = "someone@nixos.org";
86 "phone" = "+31 71 452 5670";
89 "state" = "Province of Utrecht";
96 curl --silent --compressed "$DOWNLOADSURL" \
97 | jq --raw-output '.downloads[] | .urls.Linux?[]? | select(.downloadTitle | test("^'"$PRODUCT $VERSION"'( Update)?$")) | .downloadId'
99 echo "downloadid is $DOWNLOADID"
100 test -n "$DOWNLOADID"
103 --header 'Host: www.blackmagicdesign.com' \
104 --header 'Accept: application/json, text/plain, */*' \
105 --header 'Origin: https://www.blackmagicdesign.com' \
106 --header "$USERAGENT" \
107 --header 'Content-Type: application/json;charset=UTF-8' \
108 --header "Referer: https://www.blackmagicdesign.com/support/download/$REFERID/Linux" \
109 --header 'Accept-Encoding: gzip, deflate, br' \
110 --header 'Accept-Language: en-US,en;q=0.9' \
111 --header 'Authority: www.blackmagicdesign.com' \
112 --header 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \
113 --data-ascii "$REQJSON" \
115 "$SITEURL/$DOWNLOADID")
116 echo "resolveurl is $RESOLVEURL"
119 --retry 3 --retry-delay 3 \
120 --header "Upgrade-Insecure-Requests: 1" \
121 --header "$USERAGENT" \
122 --header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" \
123 --header "Accept-Language: en-US,en;q=0.9" \
129 # The unpack phase won't generate a directory
133 appimageName = "DaVinci_Resolve_${lib.optionalString studioVariant "Studio_"}${version}_Linux.run";
137 export HOME=$PWD/home
141 test -e ${lib.escapeShellArg appimageName}
142 appimage-run ${lib.escapeShellArg appimageName} -i -y -n -C $out
144 mkdir -p $out/{configs,DolbyVision,easyDCP,Fairlight,GPUCache,logs,Media,"Resolve Disk Database",.crashreport,.license,.LUT}
151 for program in $out/bin/*; do
152 isELF "$program" || continue
153 addDriverRunpath "$program"
156 for program in $out/libs/*; do
157 isELF "$program" || continue
158 if [[ "$program" != *"libcudnn_cnn_infer"* ]];then
160 addDriverRunpath "$program"
163 ln -s $out/libs/libcrypto.so.1.1 $out/libs/libcrypt.so.1
168 name = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
169 desktopName = "Davinci Resolve${lib.optionalString studioVariant " Studio"}";
170 genericName = "Video Editor";
171 exec = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
172 icon = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
173 comment = "Professional video editing, color, effects and audio post-processing";
186 inherit (davinci) pname version;
188 targetPkgs = pkgs: with pkgs; [
205 libxcrypt # provides libcrypt.so.1
213 xdg-utils # xdg-open needed to open URLs
233 xorg.xcbutilrenderutil
239 extraPreBwrapCmds = lib.optionalString studioVariant ''
240 mkdir -p ~/.local/share/DaVinciResolve/license || exit 1
243 extraBwrapArgs = lib.optionals studioVariant [
244 "--bind \"$HOME\"/.local/share/DaVinciResolve/license ${davinci}/.license"
247 runScript = "${bash}/bin/bash ${
248 writeText "davinci-wrapper"
250 export QT_XKB_CONFIG_ROOT="${xkeyboard_config}/share/X11/xkb"
251 export QT_PLUGIN_PATH="${davinci}/libs/plugins:$QT_PLUGIN_PATH"
252 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib32:${davinci}/libs
253 ${davinci}/bin/resolve
257 extraInstallCommands = ''
258 mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps
259 ln -s ${davinci}/share/applications/*.desktop $out/share/applications/
260 ln -s ${davinci}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve${lib.optionalString studioVariant "-studio"}.png
265 updateScript = lib.getExe (writeShellApplication {
266 name = "update-davinci-resolve";
267 runtimeInputs = [ curl jq common-updater-scripts ];
270 drv=pkgs/applications/video/davinci-resolve/default.nix
271 currentVersion=${lib.escapeShellArg davinci.version}
272 downloadsJSON="$(curl --fail --silent https://www.blackmagicdesign.com/api/support/us/downloads.json)"
274 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)"
275 update-source-version davinci-resolve "$latestLinuxVersion" --source-key=davinci.src
277 # Since the standard and studio both use the same version we need to reset it before updating studio
278 sed -i -e "s/""$latestLinuxVersion""/""$currentVersion""/" "$drv"
280 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)"
281 update-source-version davinci-resolve-studio "$latestStudioLinuxVersion" --source-key=davinci.src
287 description = "Professional video editing, color, effects and audio post-processing";
288 homepage = "https://www.blackmagicdesign.com/products/davinciresolve";
289 license = licenses.unfree;
290 maintainers = with maintainers; [ amarshall jshcmpbll orivej ];
291 platforms = [ "x86_64-linux" ];
292 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
293 mainProgram = "davinci-resolve${lib.optionalString studioVariant "-studio"}";