anchor.diff:      ffmpeg-full libogg libtheora x264 x265 libvpx dav1d
       libopus lame libvorbis a52dec speex libsamplerate
       libiconv fribidi fontconfig freetype libass jansson libxml2 harfbuzz
  -    libdvdread libdvdnav libdvdcss libbluray lzma numactl
  -  ] ++ lib.optionals useGtk [
  +    libdvdread libdvdnav libdvdcss libbluray lzma
  +  ] ++ lib.optional (!stdenv.isDarwin) numactl
  +  ++ lib.optionals useGtk [
       glib gtk3 libappindicator-gtk3 libnotify
       gst_all_1.gstreamer gst_all_1.gst-plugins-base dbus-glib udev
       libgudev hicolor-icon-theme
  
positive.code:   useFdk ? false, fdk_aac ? null
  }:
  
  assert stdenv.isDarwin -> AudioToolbox != null
         && Foundation != null
         && libobjc != null
         && VideoToolbox != null;
  
  stdenv.mkDerivation rec {
    pname = "handbrake";
    version = "1.3.3";
  
negative.code: 
      patchShebangs scripts
  
      # Force using nixpkgs dependencies
      sed -i '/MODULES += contrib/d' make/include/main.defs
      sed -e 's/^[[:space:]]*\(meson\|ninja\|nasm\)[[:space:]]*= ToolProbe.*$//g' \
          -e '/    ## Additional library and tool checks/,/    ## MinGW specific library and tool checks/d' \
          -i make/configure.py
    '' + (lib.optionalString stdenv.isDarwin ''
      # Use the Nix-provided libxml2 instead of the patched version available on
      # the Handbrake website.
      substituteInPlace libhb/module.defs \
        --replace '$(CONTRIB.build/)include/libxml2' ${libxml2.dev}/include/libxml2
  
      # Prevent the configure script from failing if xcodebuild isn't available,
      # which it isn't in the Nix context. (The actual build goes fine without
      # xcodebuild.)
      sed -e '/xcodebuild = ToolProbe/s/abort=.\+)/abort=False)/' -i make/configure.py
    '') + (lib.optionalString stdenv.isLinux ''
      # Use the Nix-provided libxml2 instead of the system-provided one.
      substituteInPlace libhb/module.defs \
        --replace /usr/include/libxml2 ${libxml2.dev}/include/libxml2
    '');
  
    nativeBuildInputs = [
      pkgconfig autoconf automake libtool m4 python3
  