nvidiaPackages.production failed to build on 6.17 kernel

Let me also just link my reply to the other post here: Issues with my nvidia drivers - #5 by TLATER

Rather than upgrading the nvidia driver, I suggest downgrading the kernel (i.e. omitting the boot.kernelPackages setting and using the default) - you’ll forget to upgrade your driver otherwise, since that becomes a manual step.

Or even if you don’t, at least some people will, and I don’t like recommending a solution that is likely to create insecure systems in the long term.