Except China nobody has currently pledged this, and even the Chinese pledge is not considered credible (by some Western experts, at least):
Most states with nuclear weapons maintain policies that would permit their first use in a conflict. Pledges to only use these weapons in retaliation for a nuclear attack—or a no-first-use (NFU) policy—are rare. Where these pledges have been made by nuclear states, their adversaries generally consider them not credible.
A so-called NFU pledge, first publicly made by China in 1964, refers to any authoritative statement by a nuclear weapon state to never be the first to use these weapons in a conflict, reserving them strictly to retaliate in the aftermath of a nuclear attack against its territory or military personnel. These pledges are a component of nuclear declaratory policies. As such, there can be no diplomatic arrangement to verify or enforce a declaratory NFU pledge, and such pledges alone do not affect capabilities. States with such pledges would be technically able to still use nuclear weapons first in a conflict, and their adversaries have generally not trusted NFU assurances. Today, China is the only nuclear weapon state to maintain an unconditional NFU pledge.
Even post-cold-war US doctrine didn't rule out a preemptive strike or tactical use
The last nuclear operations doctrine, published during the George W Bush administration in 2005, also caused alarm. It envisaged pre-emptive nuclear strikes and the use of the US nuclear arsenal against all weapons of mass destruction, not just nuclear.
It was apparently formally cancelled in Feb 2006.
The revised draft included for the first time descriptions of preemptive use of US nuclear weapons, and caused the Senate Armed Services Committee to ask for a briefing, and 16 lawmakers to protest to President Bush.
The decision to cancel the doctrine document, and four other related documents, was confirmed today [2 Feb 2006] by the Pentagon.
And more recently (under Trump), the Pentagon has published and then retracted from public view a somewhat similar document.
The document, entitled Nuclear Operations, was published on 11 June [2019], and was the first such doctrine paper for 14 years. Arms control experts say it marks a shift in US military thinking towards the idea of fighting and winning a nuclear war – which they believe is a highly dangerous mindset.
“Using nuclear weapons could create conditions for decisive results and the restoration of strategic stability,” the joint chiefs’ document says. [...]
The Nuclear Operations document was taken down from the Pentagon online site after a week, and is now only available through a restricted access electronic library. [...] A spokesman for the joint chiefs of staff said the document was removed from the publicly accessible defence department website “because it was determined that this publication, as is with other joint staff publications, should be for official use only”.
And most notably during the Cold War:
In most cases, these [tactical nuclear] weapons were deployed to defend U.S. allies against aggression by the
Soviet Union and its Warsaw Pact allies, but the United States did not rule out their possible use
in contingencies with other adversaries. In Europe, these weapons were a part of NATO’s strategy
of “flexible response.” Under this strategy, NATO did not insist that it would respond to any type
of attack with nuclear weapons, but it maintained the capability to do so and to control escalation
if nuclear weapons were used. This approach was intended to convince the Soviet Union and
Warsaw Pact that any conflict, even one that began with conventional weapons, could result in
nuclear retaliation. As the Cold War drew to a close, NATO acknowledged that it would no longer maintain nuclear weapons to deter or defeat a conventional attack from the Soviet Union
and Warsaw Pact because “the threat of a simultaneous, full-scale attack on all of NATO’s European fronts has effectively been removed.” But NATO documents indicated that these
weapons would still play an important political role in NATO’s strategy by ensuring “uncertainty
in the mind of any potential aggressor about the nature of the Allies’ response to military aggression.
The above para is a pretty simplistic presentation of the US Cold War position (and mostly reflects the McNamara years). For a much more nuanced historical presentation that follows all the changes in doctrine see Nichols et al. "Tactical Nuclear Weapons and NATO".
And Russia did not shy from this view either:
In 1999, at a time when renewed war in Chechnya seemed imminent, Moscow watched with great concern as NATO waged a high-precision military campaign in Yugoslavia. The conventional capabilities that the United States and its allies demonstrated seemed far beyond Russia’s own capacities. And because the issues underlying the Kosovo conflict seemed almost identical to those underlying the Chechen conflict, Moscow became deeply worried that the United States would interfere within its borders.
By the next year, Russia had issued a new military doctrine whose main innovation was the concept of “de-escalation”—the idea that, if Russia were faced with a large-scale conventional attack that exceeded its capacity for defense, it might respond with a limited nuclear strike. To date, Russia has never publically invoked the possibility of de-escalation in relation to any specific conflict. But Russia’s policy probably limited the West’s options for responding to the 2008 war in Georgia. And it is probably in the back of Western leaders’ minds today, dictating restraint as they formulate their responses to events in Ukraine.
The exact text was (in translation)
The Russian Federation reserves the right to use nuclear weapons in response to the use of nuclear and other types of weapons of mass destruction against it and (or) its allies, as well as in response to large-scale aggression utilizing conventional weapons in situations critical to the national security of the Russian Federation.
The Russian Federation will not use nuclear weapons against states party to the Nonproliferation Treaty that do not possess nuclear weapons except in the event of an attack on the Russian Federation, the Russian Federation Armed Forces or other troops, its allies, or a state to which it has security commitments that is carried out or supported by a state without nuclear weapons jointly or in the context of allied commitments with a state with nuclear weapons.
Formally this represented a departure from the Soviet declarations...
Although the Soviet Union had pledged that it would not be the first to use nuclear weapons, most Western observers doubted that it would actually observe this pledge in a conflict. Instead, analysts argue that the Soviet Union had integrated nuclear weapons into its
warfighting plans to a much greater degree than the United States. [...]
The Soviet Union reportedly began to reduce its emphasis on nuclear warfighting strategies in the
mid-1980s, under Soviet President Mikhail Gorbachev. He reportedly believed that the use of
nuclear weapons would be catastrophic.