Deductions & credits

What you spend the sale proceeds on is immaterial ... you just cannot use those to reduce the gain calculation on the home that is sold.