Move environment sniffing stuff to CommonModule
Backporting java8-nifty-service