  The direct and secondary nuclear excitation produced by an x-ray free
electron laser when interacting with a solid-state nuclear target is
investigated theoretically. When driven at the resonance energy, the x-ray free
electron laser can produce direct photoexcitation. However, the dominant
process in that interaction is the photoelectric effect producing a cold and
very dense plasma in which also secondary processes such as nuclear excitation
by electron capture may occur. We develop a realistic theoretical model to
quantify the temporal dynamics of the plasma and the magnitude of the secondary
excitation therein. Numerical results show that depending on the nuclear
transition energy and the temperature and charge states reached in the plasma,
secondary nuclear excitation by electron capture may dominate the direct
photoexcitation by several orders of magnitude, as it is the case for the 4.8
keV transition from the isomeric state of $^{93}$Mo, or it can be negligible,
as it is the case for the 14.4 keV M\"ossbauer transition in
$^{57}\mathrm{Fe}$. These findings are most relevant for future nuclear quantum
optics experiments at x-ray free electron laser facilities.
