diff --git a/.gitignore b/.gitignore index c4a847d..71ab530 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /result +/.session diff --git a/flake.lock b/flake.lock index 32f1692..8ce9ff9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,56 +1,39 @@ { "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=", + "lastModified": 1782233679, + "narHash": "sha256-QyuGP5+QOtmXpy4i2X4DhBVBaySBdDKQEhqKcphcp34=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae", + "rev": "667d5cf1c59585031d743c78b394b0a647537c35", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-26.05", "repo": "nixpkgs", - "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae", "type": "github" } }, "nixpkgs-pinned": { "locked": { - "lastModified": 1760578826, - "narHash": "sha256-xOV1r5omtsfyPqlgxgDDuO0szHuj9BBTbaTQHgF+CAY=", + "lastModified": 1772567409, + "narHash": "sha256-qspxGige37s/66q9sptyG5VA/l2IOmMMZVJ4Xhta2wU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "497ee3c70707fd71b45c37d48ae1d45e79751047", + "rev": "e4ec59bc1152b09a4843702e4a49381194f065a2", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "497ee3c70707fd71b45c37d48ae1d45e79751047", + "rev": "e4ec59bc1152b09a4843702e4a49381194f065a2", "type": "github" } }, "root": { "inputs": { - "mesa-davinci": "mesa-davinci", "nixpkgs": "nixpkgs", "nixpkgs-pinned": "nixpkgs-pinned" } diff --git a/flake.nix b/flake.nix index da9b7b9..1a1602c 100644 --- a/flake.nix +++ b/flake.nix @@ -2,14 +2,14 @@ description = "A flake for DaVinci Resolve Studio with FFmpeg encoder plugin and patches"; inputs = { - # Main nixpkgs input - nixpkgs.url = "github:NixOS/nixpkgs/ec7c70d12ce2fc37cb92aff673dcdca89d187bae"; + # Main nixpkgs input (NixOS 26.05) + nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; - # Pinned nixpkgs input for DaVinci Resolve Studio - nixpkgs-pinned.url = "github:NixOS/nixpkgs/497ee3c70707fd71b45c37d48ae1d45e79751047"; + # Pinned nixpkgs input exclusively for the raw DaVinci Resolve Studio binary + nixpkgs-pinned.url = "github:NixOS/nixpkgs/e4ec59bc1152b09a4843702e4a49381194f065a2"; # Custom mesa input - mesa-davinci.url = "github:nixos/nixpkgs?ref=599ddd2b79331c1e6153e1659bdaab65d62c4c82"; + # mesa-davinci.url = "github:nixos/nixpkgs?ref=599ddd2b79331c1e6153e1659bdaab65d62c4c82"; }; outputs = @@ -17,27 +17,28 @@ self, nixpkgs, nixpkgs-pinned, - mesa-davinci, + # mesa-davinci, ... }@inputs: let system = "x86_64-linux"; lib = nixpkgs.lib; - # Import main pkgs with unfree allowed + # Import main pkgs (NixOS 26.05) pkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; - # Import pinned pkgs with unfree allowed + # Import pinned pkgs (Used *only* to fetch the unpatched binary) pkgs-pinned = import nixpkgs-pinned { inherit system; config.allowUnfree = true; }; - mesa-good-pkg = mesa-davinci.legacyPackages.${system}.mesa; + # mesa-good-pkg = mesa-davinci.legacyPackages.${system}.mesa; + # Built using NixOS 26.05 ffmpeg-encoder-plugin = pkgs.stdenv.mkDerivation (finalAttrs: { pname = "ffmpeg-encoder-plugin"; version = "1.2.1"; @@ -62,11 +63,13 @@ 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 @@ -80,12 +83,13 @@ ''; }); in + # Sandbox framework evaluated entirely against NixOS 26.05 pkgs.buildFHSEnv { inherit (davinci-patched) pname version; targetPkgs = - pkgs: - with pkgs; + inner-pkgs: + with inner-pkgs; [ alsa-lib aprutil @@ -111,21 +115,21 @@ python3.pkgs.numpy udev xdg-utils - libICE - libSM - libX11 - libXcomposite - libXcursor - libXdamage - libXext - libXfixes - libXi - libXinerama - libXrandr - libXrender - libXt - libXtst - libXxf86vm + libice + libsm + libx11 + libxcomposite + libxcursor + libxdamage + libxext + libxfixes + libxi + libxinerama + libxrandr + libxrender + libxt + libxtst + libxxf86vm libxcb xcbutil xcbutilimage @@ -135,9 +139,10 @@ xkeyboardconfig zlib rocmPackages.clr.icd + mesa ] ++ [ - mesa-good-pkg + # mesa-good-pkg davinci-patched ]; @@ -146,12 +151,14 @@ ''; 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" + # 1. Mount the Extras folder cleanly to the user's home directory + ''--bind "$HOME"/.local/share/DaVinciResolve/Extras /Extras'' + + # 2. Let bubblewrap safely create the required bundle subdirectory inside the existing structure + "--dir /IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64" + + # 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" ]; runScript = "${lib.getExe pkgs.bash} ${pkgs.writeText "davinci-wrapper" ''