how much of capital gain I can to HSA if I have capital loss carryover?

I am pre-retired, has no salary income, no social security, no annuity. The only income is from my investment.  I have some capital gain in this year (2020), I want to contribute to my HSA, I have family HDHP, so I know I am qualify  to contribute to HSA. IF I have capital gain $6000 in 2020, and capital loss carryover amount $2000 from 2019. My question is how to handle the capital loss carryover so I can contribute all $6000 to HSA?