Can I deduct the interest on a 401(k) loan?

No, not even if the loan is taken out to help you purchase your primary residence.