Are you sure he's dying? What signs is he exhibiting to make you think he's dying?

If you are sure he's dying, just be with him. I have had several rats (and a couple guinea pigs, and a hamster... I love rodents!), and they seem to really honestly enjoy people's company. Give him whatever he likes to eat and drink best (it seems you've already done those things). Keep him warm, and consider keeping him away from any rodent friends in his cage with him (although sometimes this isn't a good idea - two of my rats were litter mates, never separated in their lives, and they died together). If you think he's in a lot of pain, I would recommend taking him to the vet to be euthanized. I had to do that with one of mine (she had gone blind and couldn't move much or eat and was slowly starving to death), and it's not as awful as you think it might be. Then, give him a proper burial (I always buried mine in the backyard, had a little family service and then put some flowers from the yard on the grave). Anyway, I hope your rat has had a long and lovely life.