Would it be possible to build a C/C++ app with #include <os> at the top and then compile it to a fully bootable image, and then boot a real server using that?
What you are describing is an embedded system, which is done, very commonly. This thing is effectively running like an embedded system within a larger system.