Guest User

NixOS Davinci 20.2

a guest
Nov 11th, 2025
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | Source Code | 0 0
  1. final: prev:
  2. let
  3. originalResolve = prev.davinci-resolve-studio;
  4.  
  5. # Tools from pkgs
  6. bash = prev.bash;
  7. writeText = prev.writeText;
  8. xkeyboard_config = prev.xkeyboard_config;
  9. perl = prev.perl;
  10.  
  11. # Your patch set
  12. patches = [
  13. # JNE -> JMP
  14. { old = ''\x03\x00\x89\x45\xFC\x83\x7D\xFC\x00\x74\x11\x48\x8B\x45\xC8\x8B''; new = ''\x03\x00\x89\x45\xFC\x83\x7D\xFC\x00\xEB\x11\x48\x8B\x45\xC8\x8B''; }
  15. # JZ -> JMP
  16. { old = ''\x74\x11\x48\x8B\x45\xC8\x8B\x55\xFC\x89\x50\x58\xB8\x00\x00\x00''; new = ''\xEB\x11\x48\x8B\x45\xC8\x8B\x55\xFC\x89\x50\x58\xB8\x00\x00\x00''; }
  17. # SETB 1 -> SETB 0
  18. { old = ''\x41\xb6\x01\x84\xc0\x0f\x84\xb0\x00\x00\x00\x48\x85\xdb\x74\x08\x45\x31\xf6\xe9\xa3\x00\x00\x00''; new = ''\x41\xb6\x00\x84\xc0\x0f\x84\xb0\x00\x00\x00\x48\x85\xdb\x74\x08\x45\x31\xf6\xe9\xa3\x00\x00\x00''; }
  19. ];
  20.  
  21. # Compose Perl substitutions: s|OLD|NEW|g; s|...|...|g; ...
  22. perlSubs =
  23. let lib = prev.lib;
  24. in lib.concatStringsSep ";" (lib.map (p: ''s|${p.old}|${p.new}|g'') patches);
  25.  
  26. in {
  27. davinci-resolve-studio = originalResolve.override (old: {
  28. buildFHSEnv = fhs:
  29. (
  30. let
  31. # Patch the inner package where binaries live
  32. davinci = fhs.passthru.davinci.overrideAttrs (innerOld: {
  33. __intentionallyOverridingVersion = true;
  34. version = innerOld.version + "-custom-patched-v1";
  35.  
  36. nativeBuildInputs = (innerOld.nativeBuildInputs or []) ++ [ perl ];
  37.  
  38. # Patch at postFixup when $out is fully assembled
  39. postFixup = ''
  40. ${innerOld.postFixup or ""}
  41.  
  42. echo "Applying binary patches to Resolve binaries..."
  43.  
  44. # Helper to patch a file if it exists
  45. patch_if_exists() {
  46. local f="$1"
  47. if [ -f "$f" ]; then
  48. echo "Patching $f"
  49. # Read/write as raw bytes; operate on whole file
  50. ${perl}/bin/perl -0777 -Mbytes -pe '${perlSubs}' "$f" > "$f.patched" || {
  51. echo "ERROR: Patch failed for $f"
  52. exit 1
  53. }
  54. if [ ! -s "$f.patched" ]; then
  55. echo "ERROR: Patch produced empty output for $f"
  56. exit 1
  57. fi
  58. mv "$f.patched" "$f"
  59. chmod +x "$f" || true
  60. else
  61. echo "Skip: $f not found"
  62. fi
  63. }
  64.  
  65. # Common locations in the DaVinci package layout
  66. patch_if_exists "$out/bin/resolve"
  67. patch_if_exists "$out/opt/resolve/bin/resolve"
  68.  
  69. echo "Binary patching complete."
  70. echo "Installing license file…"
  71. mkdir -p $out/.license
  72. # Option B: embed the license text directly
  73. cat > $out/.license/blackmagic.lic <<'EOF'
  74. LICENSE blackmagic davinciresolvestudio 999999 permanent uncounted
  75. hostid=ANY issuer=CGP customer=CGP issued=28-dec-2023
  76. akey=0000-0000-0000-0000 _ck=00 sig=\"00\"
  77. EOF
  78. '';
  79. });
  80. in
  81. # Outer FHS wrapper referencing the patched inner package
  82. old.buildFHSEnv (fhs // {
  83. extraBwrapArgs = [
  84. ];
  85. runScript = "${bash}/bin/bash ${writeText "davinci-wrapper" ''
  86. export QT_XKB_CONFIG_ROOT="${xkeyboard_config}/share/X11/xkb"
  87. export QT_PLUGIN_PATH="${davinci}/libs/plugins:$QT_PLUGIN_PATH"
  88. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib32:${davinci}/libs
  89. unset QT_QPA_PLATFORM
  90. ${davinci}/bin/resolve
  91. ''}";
  92. extraInstallCommands = ''
  93. mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps
  94. ln -s ${davinci}/share/applications/*.desktop $out/share/applications/
  95. ln -s ${davinci}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve-studio.png
  96. '';
  97. passthru = { inherit davinci; };
  98. })
  99. );
  100. });
  101. }
Advertisement
Add Comment
Please, Sign In to add comment