Were did the idiom nut come from?

An idiom is a phrase that cannot be defined literally. Nut is a word, not an idiom. It is a Germanic word.