The Shulchan Arukh (Orach Chaim 231:1), following the Talmud (Sukkah 26b) [English here], rules that napping for more than half an hour is forbidden and even that little sleep should only be undertaken if your intent is to gain strength so you can learn Torah and serve God better. This is quite a startling ruling. Is even an elderly or sick person really forbidden to take a long nap, absent an urgent health need?
The Mishnah Berurah (4:36) quotes the Machatzis Ha-Shekel who sensibly reframes the issue subjectively. It all depends on a person’s physical situation and intentions. Napping for pleasure is improper; the day is short and there is much work to do. Napping to regain strength so you can do that work is acceptable. Presumably, all would allow someone who has functioned for days on little sleep to take a nap in order to regain his abilities. The Arukh Ha-Shulchan (Orach Chaim 231:3) points out that the Talmud seems to conclude that napping is permitted and therefore suggests, albeit inconclusively, that this subjective approach was the Shulchan Arukh‘s view.