Revert "cleaned up and added comments"

This reverts commit 69301fad1b.
This commit is contained in:
2026-06-25 17:35:15 +01:00
parent 69301fad1b
commit c9859df9bd

View File

@@ -2,10 +2,14 @@
description = "A flake for DaVinci Resolve Studio with FFmpeg encoder plugin and patches"; description = "A flake for DaVinci Resolve Studio with FFmpeg encoder plugin and patches";
inputs = { inputs = {
# Main nixpkgs input (NixOS 26.05)
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
# Version of nixpkgs just before davinci updated to 20.3.3 (which patches this) # Pinned nixpkgs input exclusively for the raw DaVinci Resolve Studio binary
nixpkgs-pinned.url = "github:NixOS/nixpkgs/e4ec59bc1152b09a4843702e4a49381194f065a2"; nixpkgs-pinned.url = "github:NixOS/nixpkgs/e4ec59bc1152b09a4843702e4a49381194f065a2";
# Custom mesa input
# mesa-davinci.url = "github:nixos/nixpkgs?ref=599ddd2b79331c1e6153e1659bdaab65d62c4c82";
}; };
outputs = outputs =
@@ -13,23 +17,28 @@
self, self,
nixpkgs, nixpkgs,
nixpkgs-pinned, nixpkgs-pinned,
# mesa-davinci,
... ...
}: }@inputs:
let let
system = "x86_64-linux"; system = "x86_64-linux";
lib = nixpkgs.lib; # For compatibility lib = nixpkgs.lib;
# Allow unfree in nixpkgs # Import main pkgs (NixOS 26.05)
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
# Import pinned pkgs (Used *only* to fetch the unpatched binary)
pkgs-pinned = import nixpkgs-pinned { pkgs-pinned = import nixpkgs-pinned {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
# Build derivation of ffmpeg encoder # mesa-good-pkg = mesa-davinci.legacyPackages.${system}.mesa;
# Built using NixOS 26.05
ffmpeg-encoder-plugin = pkgs.stdenv.mkDerivation (finalAttrs: { ffmpeg-encoder-plugin = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "ffmpeg-encoder-plugin"; pname = "ffmpeg-encoder-plugin";
version = "1.2.1"; version = "1.2.1";
@@ -50,34 +59,34 @@
''; '';
}); });
# Failed attempt to stop davinci rebuilding every time
davinci-locked = pkgs-pinned.davinci-resolve-studio;
davinci-resolve-studio-cracked = davinci-resolve-studio-cracked =
let let
davinci-patched =
let
# ONLY this specific line touches the pinned repository
davinci-locked = pkgs-pinned.davinci-resolve-studio;
in
davinci-locked.davinci.overrideAttrs (old: {
postInstall = ''
${old.postInstall or ""}
# Patched using 26.05 perl tools
${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
# Patching step mkdir -p $out/IOPlugins
davinci-patched = davinci-locked.davinci.overrideAttrs (old: { mkdir -p $out/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64
postInstall = '' cp ${ffmpeg-encoder-plugin}/ffmpeg_encoder_plugin.dvcp $out/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64/
${old.postInstall or ""} '';
});
# Patch davinci binary
${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
# Make dummy license file
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
'';
});
in in
# Build davinci sandbox # Sandbox framework evaluated entirely against NixOS 26.05
pkgs.buildFHSEnv { pkgs.buildFHSEnv {
inherit (davinci-patched) pname version; inherit (davinci-patched) pname version;
# Taken from davinci's package.nix (not sure if even necessary)
targetPkgs = targetPkgs =
inner-pkgs: inner-pkgs:
with inner-pkgs; with inner-pkgs;
@@ -99,7 +108,6 @@
libuuid libuuid
libxcrypt libxcrypt
libxkbcommon libxkbcommon
mesa
nspr nspr
ocl-icd ocl-icd
opencl-headers opencl-headers
@@ -131,33 +139,28 @@
xkeyboardconfig xkeyboardconfig
zlib zlib
rocmPackages.clr.icd rocmPackages.clr.icd
mesa
] ]
++ [ ++ [
# Custom patched davinci # mesa-good-pkg
davinci-patched davinci-patched
]; ];
# Make user facing directories
extraPreBwrapCmds = '' extraPreBwrapCmds = ''
mkdir -p ~/.local/share/DaVinciResolve/Extras || exit 1 mkdir -p ~/.local/share/DaVinciResolve/Extras || exit 1
mkdir -p ~/.local/share/DaVinciResolve/IOPlugins || exit 1
''; '';
extraBwrapArgs = [ extraBwrapArgs = [
# Mount extras folder to home # 1. Mount the Extras folder cleanly to the user's home directory
''--bind "$HOME"/.local/share/DaVinciResolve/Extras /Extras'' ''--bind "$HOME"/.local/share/DaVinciResolve/Extras /Extras''
# Set up bwrap dir for ffmpeg plugin # 2. Let bubblewrap safely create the required bundle subdirectory inside the existing structure
"--dir /IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64" "--dir /IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64"
# Mount bundle file into correct location # 3. Mount the built plugin file directly into its bundle location
"--ro-bind ${ffmpeg-encoder-plugin}/ffmpeg_encoder_plugin.dvcp /IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64/ffmpeg_encoder_plugin.dvcp" "--ro-bind ${ffmpeg-encoder-plugin}/ffmpeg_encoder_plugin.dvcp /IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64/ffmpeg_encoder_plugin.dvcp"
# Bind IOPlugins to home after plugin install to avoid weird linking behaviour
''--bind "$HOME"/.local/share/DaVinciResolve/IOPlugins /IOPlugins''
]; ];
# Wrapper to stop wayland nonsense from occuring (Use I3 if you want to use 2 screen mode)
runScript = "${lib.getExe pkgs.bash} ${pkgs.writeText "davinci-wrapper" '' runScript = "${lib.getExe pkgs.bash} ${pkgs.writeText "davinci-wrapper" ''
export QT_XKB_CONFIG_ROOT="${pkgs.xkeyboard_config}/share/X11/xkb" export QT_XKB_CONFIG_ROOT="${pkgs.xkeyboard_config}/share/X11/xkb"
export QT_PLUGIN_PATH="${davinci-patched}/libs/plugins:$QT_PLUGIN_PATH" export QT_PLUGIN_PATH="${davinci-patched}/libs/plugins:$QT_PLUGIN_PATH"
@@ -167,14 +170,12 @@
${davinci-patched}/bin/resolve ${davinci-patched}/bin/resolve
''}"; ''}";
# Application entries
extraInstallCommands = '' extraInstallCommands = ''
mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps 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}/share/applications/*.desktop $out/share/applications/
ln -s ${davinci-patched}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve-studio.png ln -s ${davinci-patched}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve-studio.png
''; '';
# Stolen update script that doesnt work lol
passthru = { passthru = {
inherit davinci-patched; inherit davinci-patched;
updateScript = lib.getExe ( updateScript = lib.getExe (
@@ -204,7 +205,6 @@
}; };
}; };
in in
# Provide default package
{ {
packages.${system} = { packages.${system} = {
davinci-resolve-studio-cracked = davinci-resolve-studio-cracked; davinci-resolve-studio-cracked = davinci-resolve-studio-cracked;