He attributed it to the Prophet ﷺ, who said, "Whoever comes to his bed intending to rise and pray during the night, but sleep overcomes him until morning, will have recorded for him what he intended, and his sleep will be a charity granted to him from his Lord." Sufyan differed with him.
أخبرنا هارون بن عبد الله قال حدثنا حسين بن علي عن زائدة عن سليمان عن حبيب بن أبي ثابت عن عبدة بن أبي لبابة عن سويد بن غفلة
يبلغ به النبي ﷺ قال من أتى فراشه وهو ينوي أن يقوم يصلي من الليل فغلبته عيناه حتى أصبح كتب له ما نوى وكان نومه صدقة عليه من ربه عز وجل خالفه سفيان
Sahih. Ibn Majah related it in the Book of Establishing Prayers, chapter on what has been said about one who sleeps through his nightly portion, hadith 1344, from Harun bin Abdullah Hammal, with this wording. It is also in Kubra, hadith 1459. Hakim graded it sahih according to the standard of the two Shaykhs, 1/311, and Dhahabi agreed with him.Sulayman here is Amash, and his student is Jufi.