My shop had a small apartment in the front building. (no kitchen tho) I stayed there for about 4 years. It took some getting use to, but hey, I was never late for work

Really was not legal for me to live there tho, (zoned Industrial) and luckily moved out several weeks before the gestapo arrived.

They were convinced that someone was living there. They interviewed all the neighbors, and my friends set them straight!
My abode in planning is a garage with a loft apartment. Finally legal to do that now at my new property. Minimum requirements are 840 sq ft of living space, 2ft overhangs and nothing narrower than 24 feet wide. (of course, all the other code stuff)
Make sure you have plenty of windows tho. Biggest drawback I had at the shop apt. One tiny window. Probably why the gestapo never found out!