Results of first-principles, density-functional, full-potential calculations on crystalline CaNiN and on single chains of NiN and CaNiN are presented. For crystalline CaNiN and single NiN chains we optimized the structural parameters. The role of dimensionality and charge transfer on the electronic structure is investigated by considering various related hypothetical crystalline structures of CaNiN where we have systematically turned off different interactions. This is achieved by expanding the lattice in different directions and/or rotating the layers of the NiN chains as well as considering structures where the Ca atoms have been removed. This is an unusual study of the dimensionality and charge effects in a crystalline compound and, although it is particularly well suited for CaNiN, it could also be applied to other quasi-low-dimensional materials like high-T c superconductors and quasi-one-dimensional spin-density materials. Finally, we explore the magnetic properties of pure CaNiN.