  Possibilities of turning intrinsically n-type oxide semiconductors like ZnO
and Zn$_{1-x}$Mg$_x$O into p-type materials are investigated. Motivated by
recent experiments on Zn$_{1-x}$Mg$_x$O doped with nitrogen we analyze the
electronic defect levels of point defects N$_{{\rm O}}$, v$_{{\rm Zn}}$, and
N$_{{\rm O}}$-v$_{{\rm Zn}}$ pairs in ZnO and Zn$_{1-x}$Mg$_x$O by means of
self-interaction-corrected density functional theory calculations. We show how
the interplay of defects can lead to shallow acceptor defect levels, although
the levels of individual point defects N$_{{\rm O}}$ are too deep in the band
gap for being responsible for p-type conduction. We relate our results to
p-type conduction paths at grain boundaries seen in polycrystalline ZnO and
develop an understanding of a p-type mechanism which is common to ZnO,
Zn$_{1-x}$Mg$_x$O, and related materials.
