Make it possible to select a derivation to use. This also moves some logic that belongs to the derivation back into it.