Local package build fails with exact configuration as on nixpkgs

Hi!
I’m trying to replicate build of telegram-desktop package (nixpkgs github link).

(Originally I was trying to install third-party Telegram client “AyuGram” using Telegram’s derivation as a base, but encountered exactly the same error, so I tried to build original package without changing anything).

I copied whole telegram-desktop directory into my dotfiles, called pkgs.libsForQt5.callPackage on it in pkgs.libsForQt5 context (screenshot below).

image1

Then just added it in my home-manager config to home.packages.

When I try building it, build fails with error
error: 'int64_t' in namespace 'std' does not name a type
(error is on screenshot + full text is linked below).

Google says it’s because of incorrectly set C++ standard, but it’s strange, considering 1/3 of the package was built successfully. Trying to install the same version of telegram-desktop directly from nixpkgs, results in successful install (it just downloads binary from cache).

Am I missing something in the package import chain that exists on nixpkgs, but not on my setup?

My pkgs directory in case somebody wants to try replicating issue: https://mega.nz/file/PYk1AarB#Aerk7_WyCMVbqiTXoKOYFZVcZc2h5h9kZLcRfcAY_Ok

Full build log for failed build: error.txt (ajg0dv02) - PasteCode.io

I’ve also found this build log, which probably corresponds to successful build of nixpkgs telegram-desktop (downloaded from binary cache): success.txt (dmfwidsq) - PasteCode.io

I used diffchecker on those two, for some reason my build can’t find some stuff, which is strange considering it’s built from the same configuration. Untitled diff - Diffchecker (mine is on the left)

UPD: I was trying it a week ago, since then nixpkgs package for telegram-desktop got updated for newer Telegram version. I’ll try building it when I’ll have time.
Stuff above in post is written when this commit was latest in telegram-desktop directory: telegram-desktop: 4.15.1 -> 4.15.2 · NixOS/nixpkgs@3f178e4 · GitHub

UPD2: Tried with latest package (4.16.1), same error: error2.txt (cjq4p4d9) - PasteCode.io