I was unable to find a straightforward guide on how to get internet access inside a NixOS container. So upon figuring it out, I am sharing.
Container
networking.useHostResolvConf = false;
services.resolved.enable = true;
Host
networking.nat.enable = true;
Disclaimer: at the time of writing, I do not have a good understanding of these things whatsoever. So there very well may be some other host options required that I’m not aware of that I already happen to have set on my system. If you’re aware of any of these, do let me know and I’ll update the post.