Nerd - an unstylish, unattractive, or socially inept person; especially : one slavishly devoted to intellectual or academic pursuits
- Webster's dictionary
By your first definition it would be INTJ. An INTP can pursue intellectual interests pretty much anywhere. INTJ's require that they are academic, that there's been some amount of debate on a subject before they will pursue it. This is because they have Te which demands that there's already a system in place before they show up. They're intellectually late, kind of like being fashionably late.
Oh and I don't think that intellectual and academic pursuits are mutually exclusive as the definition might suppose. Rather, I think that academic pursuits are a subdivision of intellectual ones.
Oh and INTPs are way too socially aware to be truly nerdy while INTJs seem to be on Pluto most of the time. Anyone wanna tell them that it isn't a planet anymore?
"... you think deeply about stuff [that] nobody cares about and hardly anybody can understand you." ~ Peguy talking about Ni users. So true.