We derive the density profile for collisionless dissipationless dark matter haloes in hierarchical cosmologies making use of the secondary infall (SI) model. The novelties are (i) we deal with triaxial virialized objects, (ii) their seeds in the linear regime are peaks endowed with unconvolved spherically averaged density profiles according to the peak formalism, (iii) the initial peculiar velocities are taken into account and (iv) accreting haloes are assumed to develop from the inside out, keeping the instantaneous inner system unaltered. The validity of this latter assumption is accurately checked by comparing analytical predictions on such a growth with the results of numerical simulation. We show that the spherically averaged density profile of virialized objects can be inferred with no need to specify their shape. The typical spherically averaged halo density profile is inferred, down to arbitrarily small radii, from the power spectrum of density perturbations. The predicted profile in the Λ cold dark matter cosmology is approximately described by an Einasto profile, meaning that it does not have a cusp but rather a core, where the inner slope slowly converges to zero. Down to one-hundredth the total radius, the profile has the right NFW and Einasto forms, being close to the latter down to a radius of about four orders of magnitude less. The inner consistency of the model implies that the density profiles of haloes harbour no information on their past aggregation history. This would explain why major mergers do not alter the typical density profile of virialized objects formed by SI and do not invalidate the peak formalism based on such a formation.