A derivation of the KSFR relation