Does the gift of the Holy Spirit come to dwell within us after we repent of our sins, or does it take up home within us after the act of baptism?
"Then Peter said to them, "Repent, and let every one of you be baptized in the name of Jesus Christ for the remission of sins; and you shall receive the gift of the Holy Spirit. For the promise is to you and to your children, and to all who are afar off, as many as the Lord our God will call." (Acts 2:38-39).
It appears you are making an assumption that Peter is stating that the gift is the Holy Spirit. Yet the wording here allows it to be read that what is being offered is the Holy Spirit's gift. Notice also that "gift" is singular and not plural. There is one gift under consideration.
But first, in answer to your question, Peter states that two conditions must first be met: repentance and baptism in order to receive forgiveness of sins. Having had our sins forgiven we receive the gift of the Holy Spirit. The use of the word "and" makes both conditions important in order to receive what follows.
See the article "Indwelling" for a detailed explanation of what the indwelling of the Spirit means. See the answer to the question "What are the gifts of the Holy Spirit?" for an explanation of what is the gift of the Holy Spirit.