That's why they were able to develop nuclear weapons in the first place.
Ukraine has invaded Russia here and there during the war even though Russia has nuclear weapons.
The argument is weak, because in general the countries that have nuclear weapons wouldn't be invaded even if nuclear weapons did not exist.
It shouldn't matter if a country's territory is occupied or not if nuclear weapons are the ultimate deterrent.
Even the US - Israel's main backer - basically treated Egyptian and Syrian war aims as legitimate.
There is a widespread belief that Israel would have used nuclear weapons if the Syrians and Egyptians had broken through to Israeli territory, and that this was one of the major American motivations for resupplying the Israelis during the war.