Was it just for kings and nobility or would peasants have long hair as well?
I believe this depended on the period! For instance, the Merovingian kings who preceded the Carolingian dynasty were often referred to as the long-haired or unshorn kings, as they wore their hair long (in contrast to the Carolingians, who cut their hair short).
But I can't speak at all to the peasantry: someone else would need to pick up on that.
Hey! I have touched on some of the dynamics of long hair in Merovingian regnal culture and early medieval society previously on this sub. You may find it helpful-- I am also happy to attempt responses to any follow-ups you may have :)