Iran has been attacking Israel for the last 30 years and everyone seems to agree that Israel has nukes… so clearly nukes don’t actually work as a deterrent, unless (again according to many comments here) you attack a genocidal state who’s only goal is to kill everyone but not use the only weapon at your disposal that can actually accomplish that goal.
Iraq also attacked an allegedly nuclear capable Israel without fear of a nuclear reprisal.