WiFi Error: "Failed to connect to network"
Do you have custom recovery installed? I have had this problem twice on a Galaxy S2, and what fixed it for me every time was running a permissions fix from recovery mode.

If that doesn't work, try deleting your WiFi config file. Not sure what it is on the Nexus, but I'm guessing it'll be something along the lines of /data/misc/wifi/wpa_supplicant.conf or /data/misc/wifi/wpa.conf. Obviously you should make backups before deleting anything. Note that you'll lose all your WiFi settings if you do this.