There's no doubt that actually launching a nuclear first strike would be the end of the regime, and they know it. But they still quite rationally want a nuclear deterrent so they can achieve a balance of power with Israel and insurance against an American invasion.
So war is not a foregone conclusion, even if they really manage to build a nuclear weapon, and if they could credibly threaten to deliver it, which is much harder and not at all certain.
Consider that a nation like China values stability and plays for the long term, and yet they've been willing to continue backing Iran. Clearly China has evaluated the Iranian regime and decided it's stable enough to rely on. My money is on China knowing what they're doing.
The push for war has everything to do with the US and Israel wanting to maintain overwhelming military dominance. Iran is not a realistic threat to the existence of Israel or US security. But it's a threat to American regional hegemony.