Psalm 25: "1 To you, O LORD, I lift up my soul. 2 O my God, in you I trust; let me not be put to shame; let not my enemies exult over me. 3 Indeed, none who wait for you shall be put to shame; they shall be ashamed who are wantonly treacherous.
"4 Make me to know your ways, O LORD; teach me your paths. 5 Lead me in your truth and teach me, for you are the God of my salvation; for you I wait all the day long.
"6 Remember your mercy, O LORD, and your steadfast love, for they have been from of old. 7 Remember not the sins of my youth or my transgressions; according to your steadfast love remember me, for the sake of your goodness, O LORD!
"8 Good and upright is the LORD; therefore he instructs sinners in the way. 9 He leads the humble in what is right, and teaches the humble his way. 10 All the paths of the LORD are steadfast love and faithfulness, for those who keep his covenant and his testimonies. 11 For your name's sake, O LORD, pardon my guilt, for it is great. 12 Who is the man who fears the LORD? Him will he instruct in the way that he should choose. 13 His soul shall abide in well-being, and his offspring shall inherit the land. 14 The friendship of the LORD is for those who fear him, and he makes known to them his covenant. 15 My eyes are ever toward the LORD, for he will pluck my feet out of the net.
"16 Turn to me and be gracious to me, for I am lonely and afflicted. 17 The troubles of my heart are enlarged; bring me out of my distresses. 18 Consider my affliction and my trouble, and forgive all my sins.
"19 Consider how many are my foes, and with what violent hatred they hate me. 20 Oh, guard my soul, and deliver me! Let me not be put to shame, for I take refuge in you. 21 May integrity and uprightness preserve me, for I wait for you.
"22 Redeem Israel, O God, out of all his troubles."
Philippians 1:21: "For to me to live is Christ, and to die is gain."
2 Thessalonians 3:3: "But the Lord is faithful. He will establish you and guard you against the evil one."
Titus 3:4-7: "4 But when the goodness and loving kindness of God our Savior appeared, 5 he saved us, not because of works done by us in righteousness, but according to his own mercy, by the washing of regeneration and renewal of the Holy Spirit, 6 whom he poured out on us richly through Jesus Christ our Savior, 7 so that being justified by his grace we might become heirs according to the hope of eternal life."
+++
The text is public domain:
1 In God, my faithful God,I trust when dark my road;Great woes may overtake me,Yet He will not forsake me.My troubles He can alter;His hand lets nothing falter.2 My sins fill me with care,Yet I will not despair.I build on Christ, who loves me;From this rock nothing moves me.To Him I will surrender,To Him, my soul's defender.3 If death my portion be,It brings great gain to me;It speeds my life's endeavorTo live with Christ forever.He gives me joy in sorrow,Come death now or tomorrow.4 O Jesus Christ, my Lord,So meek in deed and word,You suffered death to save usBecause Your love would have usBe heirs of heav'nly gladnessWhen ends this life of sadness.5 "So be it," then, I sayWith all my heart each day.Dear Lord, we all adore You,We sing for joy before You.Guide us while here we wanderUntil we praise You yonder.
+++
Psalm 25 is the main source for the hymn. Verses 2 and 22 appear in the first verse ("In God, my faithful God, / I trust when dark my road... My troubles He can alter"); verses 16-20 in the second verse ("My sins fill me with care..."); and verses 4-5, 8-9, and 12 near the end of the fifth verse ("Guide us while here we wander").
Philippians 1:21 is paraphrased at the beginning of the third verse: "If death my portion be, / It brings great gain to me."
2 Thessalonians 3:3 is the basis for the description "Him, my soul's defender" at the end of the second verse.
The passage from Titus 3 (particularly the "heirs" in verse 7) appears in the fourth verse.
+++
The imagery in the lines "I build on Christ, who loves me; / From this rock nothing moves me" in the second verse seems to come from Matthew 7:24-25: "24 'Everyone then who hears these words of mine and does them will be like a wise man who built his house on the rock. 25 And the rain fell, and the floods came, and the winds blew and beat on that house, but it did not fall, because it had been founded on the rock.'"