We report on a compact ultrahigh vacuum deposition system developed for in situ experiments using hard x rays. The chamber can be mounted on various synchrotron beamlines for spectroscopic as well as scattering experiments in grazing incidence geometry. The deposition process is completely remotely controlled and an ellipsometer is available for online monitoring of the layer growth process. The unique sample position in the chamber allows one to perform deposition, grazing incidence x-ray experiments, and ellipsometry measurements at the same time, enabling to correlate the x-ray analysis with parameters of the growth process. Additionally, the setup can be used to study in situ chemical and structural changes in an element specific manner by x-ray absorption spectroscopy. The flexibility and versatility of the system brings new possibilities to study the chemistry and structure of surfaces and interfaces in thin films systems during their formation.