I'll start with the spoiler: They are going to die. I'm not sure exactly how long it will take (because I can't find details on reserve oxygen capacity or submarine nuclear reactors...might be classified)...but they'll either suffocate or cook--and whichever happens will be their choice. A submarine's main limitation to how long it can stay under, in the ocean, is food...but this changes dramatically when they go to space.
The reason that a submarine can stay underwater so long is that it produces its own air from the water around it. It pulls the water in, splits it into Hydrogen and Oxygen with Electrolysis, and vents the Hydrogen back into the ocean. It deals with the Carbon Dioxide by use of scrubbers that use amine as a scrubbing agent...the CO2 is then vented into the ocean as well.
The sub has oxygen tanks where it stores extra oxygen, but there isn't nearly enough in there to last as long as their food stores would. This is why power failure on a sub is a big deal. It stops producing oxygen for the crew to breathe.
When their oxygen starts to run low, they could start taking their reserve of drinking water and feeding it into the oxygen generator to produce more, but...again, this is a finite supply. While it is possible that they would dump all of their drinking water into the oxygen generator, and thus die of dehydration, it is more likely that they would attempt to ration things so that they would run out at about the same time, thus allowing for the maximum possible time in order to be rescued.
But, there's a bigger problem. A nuclear submarine dumps the heat from its reactor into the ocean. A diesel sub does the same thing with the heat from its engines. In the ocean, this is great...because water is awesome at absorbing energy. The vacuum of space? Not so much.
Contrary to popular belief, the biggest temperature danger in space isn't freezing to death...it's burning up. On Earth, we can shed heat via conduction, convection, and radiation. The first two are dependent on something being present for the heat to be absorbed by...and radiation is massively less efficient than the other two. In space, you only have radiation.
Think of a submarine in the vacuum of space as the inside of a thermos. Big insulated tube. And you have a nuclear reactor as a roommate. Things are going to get very, very hot.
So, this is where you have the choice. Do you shut down the reactor so you don't all burn to death, and hope that whatever low-power reserve generator you have doesn't either run out of fuel or cook you all before you run out of water to convert into air? Or do you leave the reactor running to maintain effectively unlimited power, but burn yourselves to a crisp within short order?
Either way...not a good ending.