I went through a similar period of soul-searching as the OP (or so I would imagine) back in November, and this is the conclusion I ultimately came to.
Even if you're willing to take e.g. a 50% paycut to write code at a nonprofit, you're likely doing more good taking the obscenely high-paying industry job and donating that half of your salary, as unsexy as that is.
Which isn't to say there aren't meaningful social problems that technology can solve, but rather that the cost/reward curve is often suboptimal if you're optimizing for impact.