I have never kept nudibranchs due to the difficulty and expense involved in satisfying their diets, but I have kept sea hares from the Dolabella genus (either auricularia or gigas - difficult to tell the difference). My Dolabella ate Chaeto, Caulerpa, and lots of dried seaweeds. Unfortunately most sea hares don't live very long, even in the wild. The longest-living ones I had were gotten as pretty much full-grown adults (no idea of the total age as a result) and were around in my tanks for a bit over a year. I was keeping a pair that spawned, and they both rapidly started to slow down a couple months after that event and showed typical gastropod old-age symptoms.
If you decide to set up a tank for nudibranchs or opisthobranchs, you need to do a lot of safeguarding to prevent them from getting injured. All powerhead intakes have to be covered by sponge that is tight-fitting or otherwise well secured. Exposed powerheads can kill them and cause them to release ink, finer mesh can trap them (although wouldn't be lethal to larger animals and usually won't trigger inking), and they can pull loose-fitting sponges off. I had the sponge-removal problem happen with my current Dolabella, and I can tell you from experience that it's no fun going about destroying the bottom part of your powerhead while trying not to hurt an uncooperative grapefruit-sized slime ball. You'll also have to avoid stocking anything that can nip at the sea slug or damage it if the sea slug jumps off the side of the tank and lands in a bad place. They land pretty hard sometimes when they fall off.
If you get a sea hare and don't have a tank that is perpetually full of algae for them to eat, you should also be prepared to do a lot of target feeding with different types of dried seaweed. My current sea hare (along with a cowrie and a few large Turbos) gets fed big pieces of dried seaweed 2-3 times per day. They can make a pretty big mess when they get big, but similarly to nudibranchs, underfeeding them is not a risk worth running since starvation is a common cause of death for sea hares in captivity.