Reading this psalm always reminds me of Uriah the Hittite first and foremost. It should not, but it does. Uriah was the one who would not sleep or give himself rest while his comrades were fighting in the field.
But the psalm is about David, and yes. . .David did swear to build a habitation for God. David cared more about God's house than he did his own house. The prophet Haggai also speaks about this, and challenged the Jews who had returned to Jerusalem because they cared more about building up their own tabernacle than they did about building God's temple. This is something those who love God should always ponder: we are on earth to build up God's temple.
1Lord, remember David, and all his afflictions:
2How he sware unto the LORD, and vowed unto the mighty God of Jacob;
3Surely I will not come into the tabernacle of my house, nor go up into my bed;
4I will not give sleep to mine eyes, or slumber to mine eyelids,
5Until I find out a place for the LORD, an habitation for the mighty God of Jacob.
6Lo, we heard of it at Ephratah: we found it in the fields of the wood.
7We will go into his tabernacles: we will worship at his footstool.
8Arise, O LORD, into thy rest; thou, and the ark of thy strength.
9Let thy priests be clothed with righteousness; and let thy saints shout for joy.
10For thy servant David's sake turn not away the face of thine anointed.
11The LORD hath sworn in truth unto David; he will not turn from it; Of the fruit of thy body will I set upon thy throne.
12If thy children will keep my covenant and my testimony that I shall teach them, their children shall also sit upon thy throne for evermore.
13For the LORD hath chosen Zion; he hath desired it for his habitation.
14This is my rest for ever: here will I dwell; for I have desired it.
15I will abundantly bless her provision: I will satisfy her poor with bread.
16I will also clothe her priests with salvation: and her saints shall shout aloud for joy.
17There will I make the horn of David to bud: I have ordained a lamp for mine anointed.
18His enemies will I clothe with shame: but upon himself shall his crown flourish.