anchor.diff:      sqlite
       unzip
       wget
  -  ] ++ stdenv.lib.optionals enableFFmpeg   [ ffmpeg ];
  +  ];
   
     patchPhase = ''
       for file in $(find src/ -type f \( -iname configure -o -iname \*.sh  \) ); do
  -      substituteInPlace "$file" \
  -        --replace "/bin/bash" "${bashInteractive}/bin/bash"
  +      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
     '';
  -
  -  configureScript = "./configure";
   
     configureFlags = [
             "--disable-examples"
  
positive.code: { lib
  , stdenv
  , autoconf
  , automake
  , bash
  , bashInteractive
  , c-ares
  , cryptopp
  , curl
  , doxygen
  , fetchFromGitHub
  , hicolor-icon-theme
  , libmediainfo
  , libraw
  
negative.code:           "--with-cares"
            "--with-cryptopp"
            "--with-curl"
            "--with-ffmpeg"
            "--without-freeimage"  # unreferenced even when found
            "--without-readline"
            "--without-termcap"
            "--with-sodium"
            "--with-sqlite"
            "--with-zlib"
      ];
  
    postConfigure = ''
      cd ../..
    '';
  
    preBuild = ''
      qmake CONFIG+="release" MEGA.pro
      pushd MEGASync
        lrelease MEGASync.pro
        DESKTOP_DESTDIR="$out" qmake PREFIX="$out" -o Makefile MEGASync.pro CONFIG+=release
      popd
    '';
  
    meta = with stdenv.lib; {
  