We investigate the electronic and magnetic properties of NiS2, which, by varying the chemical composition substituting S by Se atoms or applying pressure, can be driven across various electronic and magnetic phase transitions. By combining several theoretical methods, we highlight the different role played by the chalcogen dimers and the volume compression in determining the phase transitions, through variations of the chalcogen p bonding-antibonding gap, the crystal-field splitting and the broadening of the bandwidths. While the generalized gradient approximation (GGA) of density-functional theory fails to reproduce the insulating nature of NiS2, it describes well the magnetic boundaries of the phase diagram. The large GGA delocalization error is corrected to a large extent by the use of GGA+U, hybrid functionals or the self-consistent COHSEX + GW approximation. We also discuss the advantages and the shortcomings of the different approximations in the various regions of the phase diagram of this prototypical correlated compound.