original stdenv modularization

This is @edolstra's branch moving some parts from setup.sh. I only fixed one conflict in a different way; see 1e389c9.

- I found a ``$_PATH`` reference which seems an unneeded leftover, but kept it for now. https://github.com/vcunat/nixpkgs/blob/82797f98f2917e164db8691b516ed7f354b40ff4/pkgs/stdenv/generic/setup.sh#L297
- I tested this by rebuilding the whole stdenv to guard against typos.