Limit cores used for building package

Hey!

Been using nixos for a while, pretty stable and good, but I have problems regarding when I do let’s say:

nix-shell -I nixpkgs=channel:nixos-unstable -p zed-editor

My PC uses all of 20 cores possible and my computer freeze on building rust package, it comes back but takes a while, I tried to limit build cores with

NIX_BUILD_CORES=16 nix-shell -I nixpkgs=channel:nixos-unstable -p zed-editor

But it didn’t help, any idea?

Thanks.

Regards,
Petar

Just one more thing, this are my specs if can help:

Operating System: NixOS 24.05
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.2
Kernel Version: 6.6.61 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 13th Gen Intel® Core™ i7-13650HX
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Graphics / NVidia 4070