From c781413e6d173b931d336fa96a79d889335e11c0 Mon Sep 17 00:00:00 2001 From: voidarc Date: Thu, 25 Jun 2026 10:55:37 +0100 Subject: [PATCH] initial --- flake.lock | 61 ++++++++++++++++ flake.nix | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..32f1692 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "mesa-davinci": { + "locked": { + "lastModified": 1754501210, + "narHash": "sha256-ahTHrGs72TLVcNUR2VHckEx+t6frke0e/Ptk6AaEINk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "599ddd2b79331c1e6153e1659bdaab65d62c4c82", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "599ddd2b79331c1e6153e1659bdaab65d62c4c82", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1770841267, + "narHash": "sha256-9xejG0KoqsoKEGp2kVbXRlEYtFFcDTHjidiuX8hGO44=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae", + "type": "github" + } + }, + "nixpkgs-pinned": { + "locked": { + "lastModified": 1760578826, + "narHash": "sha256-xOV1r5omtsfyPqlgxgDDuO0szHuj9BBTbaTQHgF+CAY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "497ee3c70707fd71b45c37d48ae1d45e79751047", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "497ee3c70707fd71b45c37d48ae1d45e79751047", + "type": "github" + } + }, + "root": { + "inputs": { + "mesa-davinci": "mesa-davinci", + "nixpkgs": "nixpkgs", + "nixpkgs-pinned": "nixpkgs-pinned" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..da9b7b9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,207 @@ +{ + description = "A flake for DaVinci Resolve Studio with FFmpeg encoder plugin and patches"; + + inputs = { + # Main nixpkgs input + nixpkgs.url = "github:NixOS/nixpkgs/ec7c70d12ce2fc37cb92aff673dcdca89d187bae"; + + # Pinned nixpkgs input for DaVinci Resolve Studio + nixpkgs-pinned.url = "github:NixOS/nixpkgs/497ee3c70707fd71b45c37d48ae1d45e79751047"; + + # Custom mesa input + mesa-davinci.url = "github:nixos/nixpkgs?ref=599ddd2b79331c1e6153e1659bdaab65d62c4c82"; + }; + + outputs = + { + self, + nixpkgs, + nixpkgs-pinned, + mesa-davinci, + ... + }@inputs: + let + system = "x86_64-linux"; + lib = nixpkgs.lib; + + # Import main pkgs with unfree allowed + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + # Import pinned pkgs with unfree allowed + pkgs-pinned = import nixpkgs-pinned { + inherit system; + config.allowUnfree = true; + }; + + mesa-good-pkg = mesa-davinci.legacyPackages.${system}.mesa; + + ffmpeg-encoder-plugin = pkgs.stdenv.mkDerivation (finalAttrs: { + pname = "ffmpeg-encoder-plugin"; + version = "1.2.1"; + + src = pkgs.fetchFromGitHub { + owner = "EdvinNilsson"; + repo = "ffmpeg_encoder_plugin"; + rev = "v${finalAttrs.version}"; + hash = "sha256-F4Q8YCXD5UldTwLbWK4nHacNPQ/B+4yLL96sq7xZurM="; + }; + + nativeBuildInputs = [ pkgs.cmake ]; + buildInputs = [ pkgs.ffmpeg-full ]; + + installPhase = '' + mkdir -p $out + cp ffmpeg_encoder_plugin.dvcp $out/ + ''; + }); + + davinci-resolve-studio-cracked = + let + davinci-patched = + let + davinci-locked = pkgs-pinned.davinci-resolve-studio; + in + davinci-locked.davinci.overrideAttrs (old: { + postInstall = '' + ${old.postInstall or ""} + ${lib.getExe pkgs.perl} -pi -e 's/\x74\x11\xe8\x21\x23\x00\x00/\xeb\x11\xe8\x21\x23\x00\x00/g' $out/bin/resolve + ${lib.getExe pkgs.perl} -pi -e 's/\x03\x00\x89\x45\xFC\x83\x7D\xFC\x00\x74\x11\x48\x8B\x45\xC8\x8B/\x03\x00\x89\x45\xFC\x83\x7D\xFC\x00\xEB\x11\x48\x8B\x45\xC8\x8B/' $out/bin/resolve + ${lib.getExe pkgs.perl} -pi -e 's/\x74\x11\x48\x8B\x45\xC8\x8B\x55\xFC\x89\x50\x58\xB8\x00\x00\x00/\xEB\x11\x48\x8B\x45\xC8\x8B\x55\xFC\x89\x50\x58\xB8\x00\x00\x00/' $out/bin/resolve + ${lib.getExe pkgs.perl} -pi -e 's/\x41\xb6\x01\x84\xc0\x0f\x84\xb0\x00\x00\x00\x48\x85\xdb\x74\x08\x45\x31\xf6\xe9\xa3\x00\x00\x00/\x41\xb6\x00\x84\xc0\x0f\x84\xb0\x00\x00\x00\x48\x85\xdb\x74\x08\x45\x31\xf6\xe9\xa3\x00\x00\x00/' $out/bin/resolve + touch $out/.license/blackmagic.lic + echo -e "LICENSE blackmagic davinciresolvestudio 999999 permanent uncounted\n hostid=ANY issuer=CGP customer=CGP issued=28-dec-2023\n akey=0000-0000-0000-0000 _ck=00 sig=\"00\"" > $out/.license/blackmagic.lic + + mkdir -p $out/IOPlugins + mkdir -p $out/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64 + cp ${ffmpeg-encoder-plugin}/ffmpeg_encoder_plugin.dvcp $out/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64/ + ''; + }); + in + pkgs.buildFHSEnv { + inherit (davinci-patched) pname version; + + targetPkgs = + pkgs: + with pkgs; + [ + alsa-lib + aprutil + bzip2 + dbus + expat + fontconfig + freetype + glib + libGL + libGLU + libarchive + libcap + librsvg + libtool + libuuid + libxcrypt + libxkbcommon + nspr + ocl-icd + opencl-headers + python3 + python3.pkgs.numpy + udev + xdg-utils + libICE + libSM + libX11 + libXcomposite + libXcursor + libXdamage + libXext + libXfixes + libXi + libXinerama + libXrandr + libXrender + libXt + libXtst + libXxf86vm + libxcb + xcbutil + xcbutilimage + xcbutilkeysyms + xcbutilrenderutil + xcbutilwm + xkeyboardconfig + zlib + rocmPackages.clr.icd + ] + ++ [ + mesa-good-pkg + davinci-patched + ]; + + extraPreBwrapCmds = '' + mkdir -p ~/.local/share/DaVinciResolve/Extras || exit 1 + ''; + + extraBwrapArgs = [ + ''--bind "$HOME"/.local/share/DaVinciResolve/Extras ${davinci-patched}/Extras'' + # "--dir" + # "/opt/resolve/IOPlugins" + # "--ro-bind" + # "${ffmpeg-encoder-plugin}" + # "/opt/resolve/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle" + ]; + + runScript = "${lib.getExe pkgs.bash} ${pkgs.writeText "davinci-wrapper" '' + export QT_XKB_CONFIG_ROOT="${pkgs.xkeyboard_config}/share/X11/xkb" + export QT_PLUGIN_PATH="${davinci-patched}/libs/plugins:$QT_PLUGIN_PATH" + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib32:${davinci-patched}/libs + export QT_QPA_PLATFORM=xcb + unset WAYLAND_DISPLAY + ${davinci-patched}/bin/resolve + ''}"; + + extraInstallCommands = '' + mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps + ln -s ${davinci-patched}/share/applications/*.desktop $out/share/applications/ + ln -s ${davinci-patched}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve-studio.png + ''; + + passthru = { + inherit davinci-patched; + updateScript = lib.getExe ( + pkgs.writeShellApplication { + name = "update-davinci-resolve"; + runtimeInputs = [ + pkgs.curl + pkgs.jq + pkgs.common-updater-scripts + ]; + text = '' + set -o errexit + drv=pkgs/by-name/da/davinci-resolve/package.nix + currentVersion=${lib.escapeShellArg davinci-patched.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 + + 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 + ''; + } + ); + }; + }; + in + { + packages.${system} = { + davinci-resolve-studio-cracked = davinci-resolve-studio-cracked; + default = davinci-resolve-studio-cracked; + }; + }; +}