anchor.diff: -{ lib
  -, stdenv
  +{ stdenv
   , autoconf
   , automake
  -, bash
  -, bashInteractive
   , c-ares
   , cryptopp
   , curl
   , doxygen
   , fetchFromGitHub
  +, ffmpeg
   , hicolor-icon-theme
   , libmediainfo
   , libraw
  
positive.code: , libuv
  , libzen
  , lsb-release
  , makeDesktopItem
  , pkgconfig
  , qt5
  , sqlite
  , swig
  , unzip
  , wget
  , enableFFmpeg   ? true, ffmpeg  ? ffmpeg
  }:
  
  assert enableFFmpeg   -> ffmpeg != null;
  
  stdenv.mkDerivation rec {
    name = "megasync-${version}";
  
negative.code:     sqlite
      unzip
      wget
    ];
  
    patchPhase = ''
      for file in $(find src/ -type f \( -iname configure -o -iname \*.sh  \) ); do
        substituteInPlace "$file" --replace "/bin/bash" "${stdenv.shell}"
      done
  
      # Distro and version targets attempt to use lsb_release which is broken
      # (see issue: https://github.com/NixOS/nixpkgs/issues/22729)
      substituteInPlace src/MEGASync/platform/platform.pri \
        --replace "INSTALLS += distro" "# INSTALLS += distro"
  
      # megasync target is not part of the install rule thanks to a commented block
      sed -i '/#\s*isEmpty(PREFIX)/,/#\s*INSTALLS\s*+=\s*target/s/^\s*#//' \
        src/MEGASync/MEGASync.pro
    '';
  
    dontUseQmakeConfigure = true;
  
    preConfigure = ''
      cd src/MEGASync/mega
      ./autogen.sh
    '';
  
    configureFlags = [
            "--disable-examples"
  