From German Hauptfach. Analysable as haapt- + Fach, both of which are also borrowed.
Haaptfach n (plural Haaptfächer)