We use N-body simulations of dark matter haloes in cold dark matter (CDM) and a large set of different warm dark matter (WDM) cosmologies to demonstrate that the spherically averaged density profile of dark matter haloes has a shape that depends on the power spectrum of matter perturbations. Density profiles are steeper in WDM but become shallower at scales less than one percent of the virial radius. Virialization isotropizes the velocity dispersion in the inner regions of the halo but does not erase the memory of the initial conditions in phase space. The location of the observed deviations from CDM in the density profile and in phase space can be directly related to the ratio between the halo mass and the filtering mass and are most evident in small mass haloes, even for a 34 keV thermal relic WDM. The rearrangement of mass within the haloes supports analytic models of halo structure that include angular momentum. We also find evidence of a dependence of the slope of the inner density profile in CDM cosmologies on the halo mass with more massive haloes exhibiting steeper profiles, in agreement with the model predictions and with previous simulation results. Our work complements recent studies of microhaloes near the filtering scale in CDM and strongly argue against a universal shape for the density profile.