An x-ray free-electron laser oscillator (XFELO) is a next-generation x-ray source, similar to free-electron laser oscillators at VUV and longer wavelengths but using crystals as high-reflectivity x-ray mirrors. Each output pulse from an XFELO is fully coherent with high spectral purity. The temporal coherence length can further be increased drastically, from picoseconds to microseconds or even longer, by phase-locking successive XFELO output pulses, using the narrow nuclear resonance lines of nuclei such as 57 Fe as a reference. We show that the phase fluctuation due to the seismic activities is controllable and that due to spontaneous emission is small. The fluctuation of electron-bunch spacing contributes mainly to the envelope fluctuation but not to the phase fluctuation. By counting the number of standing-wave maxima formed by the output of the nuclear-resonance-stabilized (NRS) XFELO over an optically known length, the wavelength of the nuclear resonance can be accurately measured, possibly leading to a new length or frequency standard at x-ray wavelengths. A NRS-XFELO will be an ideal source for experimental x-ray quantum optics as well as other fundamental physics. The technique can be refined for other, narrower resonances such as 181 Ta or 45 Sc.