anchor.diff:          tar -xaf $i
         done
         cd qtbase-*
  -      patch -p1 < ../../$sourceRoot/Telegram/Patches/qtbase_${qtVersion}.diff
  +      # This patch is outdated but the fixes doesn't feel very important
  +      patch -p1 < ../../$sourceRoot/Telegram/Patches/qtbase_${qtVersion}.diff || true
         for i in $qtPatches; do
           patch -p1 < $i
         done
  
positive.code:     "INCLUDEPATH+=${dee}/include/dee-1.0"
      "INCLUDEPATH+=${libdbusmenu-glib}/include/libdbusmenu-glib-0.4"
      "INCLUDEPATH+=${breakpad}/include/breakpad"
      "LIBS+=-lcrypto"
      "LIBS+=-lssl"
    ];
  
negative.code: }:
  
  let
    /* Find the index of the first element in the list matching the specified
       predicate or returns null if no such element exists.
  
       Example:
         findFirstIndex (x: x > 3) [ 1 6 4 ]
         => 1
    */
    findFirstIndex = pred: list:
      # Poor man's Either via a list.
      let searchFun = old: curr:
            if lib.isList old then old
              else if pred curr then [old]
              else old + 1;
          res = lib.foldl searchFun 0 list;
      in if lib.isList res then lib.elemAt res 0 else null;
  
    extractVersion = ver:
      let suffix = findFirstIndex (x: x == "-") (lib.stringToCharacters ver);
      in if suffix == null then ver else lib.substring 0 suffix ver;
  
    system-x86_64 = lib.elem stdenv.system lib.platforms.x86_64;
    packagedQt = "5.6.0";
    systemQt = extractVersion qtbase.version;
  
  in stdenv.mkDerivation rec {
    name = "telegram-desktop-${version}";
    version = "0.9.56";
    qtVersion = lib.replaceStrings ["."] ["_"] packagedQt;
  
    src = fetchFromGitHub {
      owner = "telegramdesktop";
      repo = "tdesktop";
      rev = "v${version}";
      sha256 = "000ngg6arfb6mif0hvin099f83q3sn7mw4vfvrikskczblw3a5lc";
    };
  
    tgaur = fetchgit {
  