2022-04-03 18:54:34 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, cacert
|
|
|
|
, curl
|
|
|
|
, runCommandLocal
|
|
|
|
, unzip
|
|
|
|
, appimage-run
|
2024-07-31 10:19:44 +00:00
|
|
|
, addDriverRunpath
|
2023-07-15 17:15:38 +00:00
|
|
|
, dbus
|
2022-04-03 18:54:34 +00:00
|
|
|
, libGLU
|
|
|
|
, xorg
|
2023-04-29 16:46:19 +00:00
|
|
|
, buildFHSEnv
|
2023-05-24 13:37:59 +00:00
|
|
|
, buildFHSEnvChroot
|
2022-04-03 18:54:34 +00:00
|
|
|
, bash
|
|
|
|
, writeText
|
|
|
|
, ocl-icd
|
|
|
|
, xkeyboard_config
|
|
|
|
, glib
|
|
|
|
, libarchive
|
2022-10-30 15:09:59 +00:00
|
|
|
, libxcrypt
|
2023-07-15 17:15:38 +00:00
|
|
|
, python3
|
2023-04-12 12:48:02 +00:00
|
|
|
, aprutil
|
2023-07-15 17:15:38 +00:00
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
2024-01-02 11:29:13 +00:00
|
|
|
, jq
|
|
|
|
|
|
|
|
, studioVariant ? false
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
, common-updater-scripts
|
|
|
|
, writeShellApplication
|
2022-04-03 18:54:34 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
davinci = (
|
|
|
|
stdenv.mkDerivation rec {
|
2024-01-02 11:29:13 +00:00
|
|
|
pname = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "18.6.6";
|
2022-04-03 18:54:34 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
(appimage-run.override { buildFHSEnv = buildFHSEnvChroot; } )
|
2024-07-31 10:19:44 +00:00
|
|
|
addDriverRunpath
|
2023-07-15 17:15:38 +00:00
|
|
|
copyDesktopItems
|
|
|
|
unzip
|
2023-05-24 13:37:59 +00:00
|
|
|
];
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
# Pretty sure, there are missing dependencies ...
|
2023-07-15 17:15:38 +00:00
|
|
|
buildInputs = [
|
|
|
|
libGLU
|
|
|
|
xorg.libXxf86vm
|
|
|
|
];
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
src = runCommandLocal "${pname}-src.zip"
|
|
|
|
rec {
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
2024-01-02 11:29:13 +00:00
|
|
|
outputHash =
|
|
|
|
if studioVariant
|
2024-04-21 15:54:59 +00:00
|
|
|
then "sha256-9iTdIjHH8uoXlVr6miyqmHuzbbpbqdJPEbPGycsccoI="
|
|
|
|
else "sha256-WrIQ1FHm65MOGb5HfFl2WzXYJRlqktuZdrtzcjWp1gI=";
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs = [ curl jq ];
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
# ENV VARS
|
|
|
|
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# Get linux.downloadId from HTTP response on https://www.blackmagicdesign.com/products/davinciresolve
|
2022-04-03 18:54:34 +00:00
|
|
|
REFERID = "263d62f31cbb49e0868005059abcb0c9";
|
2024-01-02 11:29:13 +00:00
|
|
|
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;
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
USERAGENT = builtins.concatStringsSep " " [
|
2024-01-02 11:29:13 +00:00
|
|
|
"User-Agent: Mozilla/5.0 (X11; Linux ${stdenv.hostPlatform.linuxArch})"
|
2022-04-03 18:54:34 +00:00
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
|
|
|
"Chrome/77.0.3865.75"
|
|
|
|
"Safari/537.36"
|
|
|
|
];
|
|
|
|
|
|
|
|
REQJSON = builtins.toJSON {
|
|
|
|
"firstname" = "NixOS";
|
|
|
|
"lastname" = "Linux";
|
|
|
|
"email" = "someone@nixos.org";
|
|
|
|
"phone" = "+31 71 452 5670";
|
|
|
|
"country" = "nl";
|
2024-01-25 14:12:00 +00:00
|
|
|
"street" = "-";
|
2022-04-03 18:54:34 +00:00
|
|
|
"state" = "Province of Utrecht";
|
|
|
|
"city" = "Utrecht";
|
2024-01-02 11:29:13 +00:00
|
|
|
"product" = PRODUCT;
|
2022-04-03 18:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} ''
|
2024-01-02 11:29:13 +00:00
|
|
|
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"
|
2022-04-03 18:54:34 +00:00
|
|
|
RESOLVEURL=$(curl \
|
2023-07-15 17:15:38 +00:00
|
|
|
--silent \
|
|
|
|
--header 'Host: www.blackmagicdesign.com' \
|
|
|
|
--header 'Accept: application/json, text/plain, */*' \
|
|
|
|
--header 'Origin: https://www.blackmagicdesign.com' \
|
|
|
|
--header "$USERAGENT" \
|
|
|
|
--header 'Content-Type: application/json;charset=UTF-8' \
|
|
|
|
--header "Referer: https://www.blackmagicdesign.com/support/download/$REFERID/Linux" \
|
|
|
|
--header 'Accept-Encoding: gzip, deflate, br' \
|
|
|
|
--header 'Accept-Language: en-US,en;q=0.9' \
|
|
|
|
--header 'Authority: www.blackmagicdesign.com' \
|
|
|
|
--header 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \
|
2022-04-03 18:54:34 +00:00
|
|
|
--data-ascii "$REQJSON" \
|
|
|
|
--compressed \
|
2024-01-02 11:29:13 +00:00
|
|
|
"$SITEURL/$DOWNLOADID")
|
2024-01-25 14:12:00 +00:00
|
|
|
echo "resolveurl is $RESOLVEURL"
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
curl \
|
|
|
|
--retry 3 --retry-delay 3 \
|
2023-07-15 17:15:38 +00:00
|
|
|
--header "Upgrade-Insecure-Requests: 1" \
|
|
|
|
--header "$USERAGENT" \
|
|
|
|
--header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" \
|
|
|
|
--header "Accept-Language: en-US,en;q=0.9" \
|
2022-04-03 18:54:34 +00:00
|
|
|
--compressed \
|
|
|
|
"$RESOLVEURL" \
|
|
|
|
> $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
# The unpack phase won't generate a directory
|
2023-10-09 19:29:22 +00:00
|
|
|
sourceRoot = ".";
|
2022-04-03 18:54:34 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
installPhase = let
|
|
|
|
appimageName = "DaVinci_Resolve_${lib.optionalString studioVariant "Studio_"}${version}_Linux.run";
|
|
|
|
in ''
|
2022-04-03 18:54:34 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
export HOME=$PWD/home
|
|
|
|
mkdir -p $HOME
|
|
|
|
|
|
|
|
mkdir -p $out
|
2024-01-02 11:29:13 +00:00
|
|
|
test -e ${lib.escapeShellArg appimageName}
|
|
|
|
appimage-run ${lib.escapeShellArg appimageName} -i -y -n -C $out
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
mkdir -p $out/{configs,DolbyVision,easyDCP,Fairlight,GPUCache,logs,Media,"Resolve Disk Database",.crashreport,.license,.LUT}
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
for program in $out/bin/*; do
|
|
|
|
isELF "$program" || continue
|
2024-07-31 10:19:44 +00:00
|
|
|
addDriverRunpath "$program"
|
2022-04-03 18:54:34 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for program in $out/libs/*; do
|
|
|
|
isELF "$program" || continue
|
|
|
|
if [[ "$program" != *"libcudnn_cnn_infer"* ]];then
|
|
|
|
echo $program
|
2024-07-31 10:19:44 +00:00
|
|
|
addDriverRunpath "$program"
|
2022-04-03 18:54:34 +00:00
|
|
|
fi
|
|
|
|
done
|
2023-04-12 12:48:02 +00:00
|
|
|
ln -s $out/libs/libcrypto.so.1.1 $out/libs/libcrypt.so.1
|
2022-04-03 18:54:34 +00:00
|
|
|
'';
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
2024-06-20 14:57:18 +00:00
|
|
|
name = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
|
|
|
|
desktopName = "Davinci Resolve${lib.optionalString studioVariant " Studio"}";
|
2023-07-15 17:15:38 +00:00
|
|
|
genericName = "Video Editor";
|
2024-06-20 14:57:18 +00:00
|
|
|
exec = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
|
|
|
|
icon = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
|
2023-07-15 17:15:38 +00:00
|
|
|
comment = "Professional video editing, color, effects and audio post-processing";
|
|
|
|
categories = [
|
|
|
|
"AudioVideo"
|
|
|
|
"AudioVideoEditing"
|
|
|
|
"Video"
|
|
|
|
"Graphics"
|
|
|
|
];
|
|
|
|
})
|
|
|
|
];
|
2022-04-03 18:54:34 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
in
|
2023-04-29 16:46:19 +00:00
|
|
|
buildFHSEnv {
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit (davinci) pname version;
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
targetPkgs = pkgs: with pkgs; [
|
|
|
|
alsa-lib
|
2023-07-15 17:15:38 +00:00
|
|
|
aprutil
|
2022-04-03 18:54:34 +00:00
|
|
|
bzip2
|
2023-07-15 17:15:38 +00:00
|
|
|
davinci
|
|
|
|
dbus
|
|
|
|
expat
|
|
|
|
fontconfig
|
|
|
|
freetype
|
2022-04-03 18:54:34 +00:00
|
|
|
glib
|
2023-07-15 17:15:38 +00:00
|
|
|
libGL
|
|
|
|
libGLU
|
2022-04-03 18:54:34 +00:00
|
|
|
libarchive
|
2023-07-15 17:15:38 +00:00
|
|
|
libcap
|
|
|
|
librsvg
|
|
|
|
libtool
|
|
|
|
libuuid
|
2022-10-30 15:09:59 +00:00
|
|
|
libxcrypt # provides libcrypt.so.1
|
2023-07-15 17:15:38 +00:00
|
|
|
libxkbcommon
|
|
|
|
nspr
|
|
|
|
ocl-icd
|
|
|
|
opencl-headers
|
|
|
|
python3
|
|
|
|
python3.pkgs.numpy
|
|
|
|
udev
|
2022-04-03 18:54:34 +00:00
|
|
|
xdg-utils # xdg-open needed to open URLs
|
2023-07-15 17:15:38 +00:00
|
|
|
xorg.libICE
|
|
|
|
xorg.libSM
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libXcomposite
|
|
|
|
xorg.libXcursor
|
|
|
|
xorg.libXdamage
|
|
|
|
xorg.libXext
|
|
|
|
xorg.libXfixes
|
|
|
|
xorg.libXi
|
|
|
|
xorg.libXinerama
|
|
|
|
xorg.libXrandr
|
|
|
|
xorg.libXrender
|
2024-01-02 11:29:13 +00:00
|
|
|
xorg.libXt
|
2023-07-15 17:15:38 +00:00
|
|
|
xorg.libXtst
|
|
|
|
xorg.libXxf86vm
|
|
|
|
xorg.libxcb
|
|
|
|
xorg.xcbutil
|
|
|
|
xorg.xcbutilimage
|
|
|
|
xorg.xcbutilkeysyms
|
|
|
|
xorg.xcbutilrenderutil
|
|
|
|
xorg.xcbutilwm
|
|
|
|
xorg.xkeyboardconfig
|
|
|
|
zlib
|
2022-04-03 18:54:34 +00:00
|
|
|
];
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
extraPreBwrapCmds = lib.optionalString studioVariant ''
|
|
|
|
mkdir -p ~/.local/share/DaVinciResolve/license || exit 1
|
|
|
|
'';
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
extraBwrapArgs = lib.optionals studioVariant [
|
|
|
|
"--bind \"$HOME\"/.local/share/DaVinciResolve/license ${davinci}/.license"
|
|
|
|
];
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
runScript = "${bash}/bin/bash ${
|
|
|
|
writeText "davinci-wrapper"
|
|
|
|
''
|
|
|
|
export QT_XKB_CONFIG_ROOT="${xkeyboard_config}/share/X11/xkb"
|
2023-02-02 18:25:31 +00:00
|
|
|
export QT_PLUGIN_PATH="${davinci}/libs/plugins:$QT_PLUGIN_PATH"
|
2024-01-02 11:29:13 +00:00
|
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib32:${davinci}/libs
|
2022-04-03 18:54:34 +00:00
|
|
|
${davinci}/bin/resolve
|
|
|
|
''
|
|
|
|
}";
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
extraInstallCommands = ''
|
|
|
|
mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps
|
|
|
|
ln -s ${davinci}/share/applications/*.desktop $out/share/applications/
|
|
|
|
ln -s ${davinci}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve${lib.optionalString studioVariant "-studio"}.png
|
|
|
|
'';
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
meta = with lib; {
|
2023-07-15 17:15:38 +00:00
|
|
|
description = "Professional video editing, color, effects and audio post-processing";
|
|
|
|
homepage = "https://www.blackmagicdesign.com/products/davinciresolve";
|
2022-04-03 18:54:34 +00:00
|
|
|
license = licenses.unfree;
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ amarshall jshcmpbll orivej ];
|
2023-10-09 19:29:22 +00:00
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2024-06-20 14:57:18 +00:00
|
|
|
mainProgram = "davinci-resolve${lib.optionalString studioVariant "-studio"}";
|
2022-04-03 18:54:34 +00:00
|
|
|
};
|
|
|
|
}
|