You are essentially correct. The phrase おやすみなさい（お休みなさい・御休みなさい if you are choosing to write with the characters）is a conjugation of the verb 休む (やすむ：rest, take a day off, lie down etc.), from which the noun 休み（やすみ）is also derived. So, the link is a direct one.
To be specific, おやすみなさい is a (one of various!) polite imperative form of the verb 休む. The なさい and also the more polite なさいませ suffixes** mean something along the lines of 'you should do that' or 'please do do that'. Putting that all together, おやすみなさい means something like '(please do) have a rest!', as you guessed. You probably won't use おやすみなさいませ yourself, but you might hear it as a customer, for instance when a clerk hands your keys to you, as you return to a hotel at night.
** These suffixes are derived from the verb なさる, which is the honorific form of する... I've not gone into detail as to how you actually form these conjugations, as you will doubtless study keigo (敬語：respectful speech) in depth in due course, but if you are interested, Coto Academy has a good, fairly clear introduction.