Get your taxes done using TurboTax

several questions you did not answer so I will make some assumptions  - neither you nor your spouse is cover by medicare and neither are over 65. the $6K in capital gains is long-term

 

with a fully taxable ira of $48K net long-term capital gains of $4k a standard deduction for 2020 of about $25K

your taxable income would be $27K.   

so here's the max HSA you can make for 2020

if both are under 55 years old then $7100. if you are over 55 you can contribute an extra $1000. if your spouse is over 55 she can contribute $1,000 but it must be to her HSA - there are no joint HSA's

if both over 55 then an extra  $1000 to yours and $1000 to hers. thus the max  for both $9100 

 

if the capital gains are long-term the tax on them will be $0 what the HSA does is reduce the other taxable income.  so a $6000 HSA would reduce taxable income to $21K of which $4K doesn't get taxed (the LTCG) so you end up paying tax on $17K.  if the $6K in capital gains was short-term then all $21K is taxed