A weakly nonlocal and nonlinear theory of heat conduction in rigid bodies is proposed. The constitutive equations generalize these of Fourier, Maxwell-Cattaneo and Guyer-Krumhansl. The proposed model uses the fundaments and the technique of extended irreversible thermodynamics. The main conclusion is that the presence of nonlocal terms in the transport equation for the heat flux implies a modification of the entropy flux; the latter is no longer given by its classical expression, i.e. the heat flux divided by the temperature, but contains extra contributions which are nonlinear in the heat flux and its gradient. These results arise as compatibility conditions with the second law of thermodynamics. A nonequilibrium temperature depending on the heat flux and generalizing the local equilibrium temperature is also emerging naturally from the formalism.