A group of prisoners alleging they have to drink arsenic-laden water to stay cool inside their hot Texas lockup won a legal victory Tuesday in an ongoing lawsuit after a federal judge ordered the Texas prison system to provide safe drinking water that doesn't violate "contemporary standards of decency."

U.S. District Judge Keith Ellison has given the prison system 15 days to replace the water supply at the Wallace Pack Unit in Navasota, located about 70 miles northwest of Houston.

The judge's order came in a lawsuit the inmates filed in 2014 in Houston federal court alleging they're being exposed to dangerous heat at the unit. The lawsuit alleges Texas houses inmates in conditions that are inhumane enough to violate the U.S. Constitution's protections against cruel and unusual punishment. The Pack Unit is a low security geriatric facility that houses about 1,400 inmates, many of whom are sick or disabled.

In his 15-page ruling, Ellison wrote the Texas Department of Criminal Justice has been "deliberately indifferent" to the ongoing risk inmates at the unit face from prolonged exposure to "extreme heat" and from having to drink arsenic-laden water in order to reduce the risk from the heat. The drinking water at the Pack Unit has contained between 2 and 4½ times the amount of arsenic permitted by the Environmental Protection Agency, the judge said.

The prisoners have "demonstrated that (the prison system's) current and ongoing conduct violates contemporary standards of decency," Ellison wrote.

At least 20 prisoners have died indoors in non-air-conditioned Texas prisons from overheating since 1998, including 10 who died in 2011, Ellison said.

Jason Clark, a spokesman for the Texas Department of Criminal Justice, said the agency plans to appeal the ruling.

"The water at the Pack Unit is safe to drink according to the Texas Commission on Environmental Quality and the Texas Department of State Health Services," he said in a statement. "Although this is not an emergency and the water is safe to drink, we have designed a new filtration system which has been approved by TCEQ, and the final installation is expected in early 2017."

In his ruling, Ellison highlighted that the current water filtration system was installed in 2007 in response to the EPA a year earlier lowering maximum levels of arsenic in drinking water and that the prison system has had trouble with the filtration system for years.

Jeff Edwards, one of the attorneys for the inmates, said the prison system has known about the unsafe arsenic levels in the Pack Unit's water since 2006 but has not fixed the problem "and that's not acceptable."

"When you take away people's liberty, you have to provide certain protections," he said. "Some people may have the mentality that if you've committed a crime, you lose all your rights. That is simply not the case. You do not give up your constitutional right not to be treated cruelly."

In court filings, some of the inmates have discussed living conditions at the Pack Unit.

"I sometimes feel like I'm about to die of thirst even when I am constantly drinking water," said Jackie Brannum, who has been at the unit since 2001 and is serving a sentence for aggravated sexual assault. "All I can think of is cooling down somehow."