Clearly, the Second Law of Thermodynamics precludes the existence of any theoretical device that would continue running throughout the lifetime of the universe. However, is it possible to construct a theoretical device that uses environmental thermal energy to continue running in the presence of a virtually unlimited thermal reservoir? For example, could nanotubes or some chemical compound produce an electric potential difference at room temperature that could power a bulb as long as the proximal temperature remained above some lower bound?
There are many equivalent ways of stating the 2nd Law of thermodynamics. One of these is the Kelvin statement of the second law which says
It is impossible for the net effect any process to be the the conversion of heat into work with no other effects.
or more simply not heat engine can be 100% efficient. This means that it is impossible for any device to simply take in thermal energy from the environment and to something useful with it
The simplest way to get around the Kelvin statement is for the device, as well as taking in heat from some external source it also deposits an amount of waist heat somewhere else, so that the process has an extra effect besides converting heat into work. Carnot's theorem establishes the minimum about of waist heat and shows that it depends on the ratio of the temperatures of the heat source and heat sink. In particular the heat sink must be at a lower temperature than the heat source.
This means that in order for your machine to run for ever it must have not only an infinite environment with some amount of thermal energy but a temperature gradient of some source. If you can set up 2 effectively infinite heat reservoirs at different temperature you could, in-principle, run a heat engine between them forever. In practice this is not generally possible. If your 2 law heat reservoirs are close enough together to run some sort of heat engine between them then they are probably close enough together for heat to leak from one to the other, equalizing the temperatures.