PostgreSQL password in environment variables

I’ve heard that using environment variables to provide the password and other PostgreSQL parameters is the way to go.

Is the Nitrous.io way (explained at http://help.nitrous.io/postgres/) the way you do it? Or is there a better way?