US residential solar installer Sunrun Inc (NASDAQ:RUN) has agreed to buy rival Vivint Solar (NYSE:VSLR) in an all-stock deal with an enterprise value of USD 3.2 billion (EUR 2.83bn).