Bumblebee and optimus-manager both solve this in the aur.
https://search.nixos.org/options?channel=22.05&from=0&size=5...
https://search.nixos.org/options?channel=22.05&show=hardware...
You might want to consult the unofficial wiki: https://nixos.wiki/wiki/Nvidia
(You probably want PRIME in offload mode rather than Bumblebee, which wasn't available when I set up my old NVIDIA system.)
sync mode actually stopped working for me, but that's not a big deal since the offloading works so well. I always use my GPU when I need it.
Bumblebee and optimus-manager both solve this in the aur.