I have a bit of an odd situation. I have a standard outlet (120v, 15 amps, just a normal United States receptacle). I'd like to run some raceway conduit up from the outlet*. At the other end of the raceway, I'd like to have some 12v lights. I'd also like to have these lights use a 12v dimmer switch. The dimmer is pretty standard. It goes into a normal one-gang electrical box, and takes 12v + GND in, and gives 12v + GND out (but the output is dimmed). Here's how it is wired:
Image taken from the Amazon listing, and archived with the Wayback machine to be safe.
Anyways, my original idea was to just get a standard wall-wart 120v AC to 12v DC transformer, stick it in the outlet, and then mount the switch in a raceway box like this one, and run the raceway up from it (so the transformer plugs into the outlet, and the 12v end goes into the box, say, via a hole drilled into the bottom of it, with the raceway box being a bit above the outlet).
I was thinking, though, it would be nice if I could just remove the outlet, put the box extender right where the outlet is, and then have the switch in the box extender. But, in order to do that, I would need 12v going into the in-wall box. I've seen doorbell transformers, but they appear to mostly take 120v from in the box, and make it into either 12v or 16v outside the box. But I'm wondering if there is a good (code-compliant and useful) way to do the opposite: take the 120v from outside the box, and make that into 12v in the box, effectively making the box into a low-voltage only box, to avoid the "no high and low voltage in one box" rule. Is there a good way to do that?
*The outlet is just mounted like a normal standard outlet (in the wall, the faceplate sticks out maybe a few millimeters).