  We theoretically analyze the performance of the nuclear magnetic resonance
(NMR) spectroscopy with a superconducting flux qubit (FQ). Such NMR with the FQ
is attractive because of the possibility to detect the relatively small number
of nuclear spins in a local region ($\sim\mu$m) with low temperatures ($\sim$
mK) and low magnetic fields ($\sim$ mT), in which other types of quantum
sensing schemes cannot easily access. A sample containing nuclear spins is
directly attached on the FQ, and the FQ is used as a magnetometer to detect
magnetic fields from the nuclear spins. Especially, we consider two types of
approaches to NMR with the FQ. One of them is to use spatially inhomogeneous
excitations of the nuclear spins, which are induced by a spatially asymmetric
driving with radio frequency~(RF) pulses. Such an inhomogeneity causes a change
in the DC magnetic flux penetrating a loop of the FQ, which can be detected by
a standard Ramsey measurement on the FQ. The other approach is to use a
dynamical decoupling on the FQ to measure AC magnetic fields induced by Larmor
precession of the nuclear spins. In this case, neither a spin excitation nor a
spin polarization is required since the signal comes from fluctuating magnetic
fields of the nuclear spins. We calculate the minimum detectable density
(number) of the nuclear spins for the FQ with experimentally feasible
parameters. We show that the minimum detectable density (number) of the nuclear
spins with these approaches is around $10^{21}$ /cm$^3$ ($10^8$) with an
accumulation time of a second.
