It has not rained for months, but these plants have managed to survive.

I have transformed the above sentence as follows. May I know which of the following is the correct sentence?

Thanks.

Despite the lack of rain for months, these plants have managed to survive.

Despite it not having rained for months. these plants have managed to survive.