Inorganic nitrides with wurtzite crystal structures are well-known semiconductors used in optoelectronic devices. In contrast, rocksalt-based nitrides are known for their metallic and refractory properties. Breaking this dichotomy, here we report on ternary nitride semiconductors with rocksalt crystal structures, remarkable optoelectronic properties, and the general chemical formula Mg$_{x}$TM$_{1-x}$N (TM=Ti, Zr, Hf, Nb). These compounds form over a broad metal composition range and our experiments show that Mg-rich compositions are nondegenerate semiconductors with visible-range optical absorption onsets (1.8-2.1 eV). Lattice parameters are compatible with growth on a variety of substrates, and epitaxially grown MgZrN$_{2}$ exhibits remarkable electron mobilities approaching 100 cm$^{2}$V$^{-1}$s$^{-1}$. Ab initio calculations reveal that these compounds have disorder-tunable optical properties, large dielectric constants and low carrier effective masses that are insensitive to disorder. Overall, these experimental and theoretical results highlight Mg$_{G-3}$TMN$_{G-2}$ rocksalts as a new class of semiconductor materials with promising properties for optoelectronic applications.