Self-propelling bacteria are a nanotechnology dream. These unicellular organisms are not just capable of living and reproducing, but they can swim very efficiently, sense the environment, and look for food, all packaged in a body measuring a few microns. Before such perfect machines can be artificially assembled, researchers are beginning to explore new ways to harness bacteria as propelling units for microdevices. Proposed strategies require the careful task of aligning and binding bacterial cells on synthetic surfaces in order to have them work cooperatively. Here we show that asymmetric environments can produce a spontaneous and unidirectional rotation of nanofabricated objects immersed in an active bacterial bath. The propulsion mechanism is provided by the self-assembly of motile Escherichia coli cells along the rotor boundaries. Our results highlight the technological implications of active matter's ability to overcome the restrictions imposed by the second law of thermodynamics on equilibrium passive fluids.