See also the linked page below.(a J-J dictionary)
のだ
[連語]《準体助詞「の」+断定の助動詞「だ」》
2 話し手の決意、または相手に対する要求・詰問の意を表す。「なんとしてもその夢を実現させる― ◦だ」
[補説]話し言葉では「んだ」の形をとることが多い。
http://dictionary.goo.ne.jp/leaf/jn2/171961/m0u/のだ/
"The dictionary form of a volitional verb + んだ" expresses a strong command to the addressee or the speaker's determination. んじゃない is its negated version, thus, it means an order not to do~; "Don't~/You must not~".
朝ご飯を食べるんだ
You must eat breakfast.
朝ご飯を食べるんじゃない
You must not eat breakfast.
As Glenn-san explained, んじゃなかった can be considered as the past tense of this nagated form, "I shouldn't
do at that time", i.e., "I actually
did at that time and regret it now".
朝ご飯を食べるんじゃなかった
I shouldn't have eaten breakfast. (= I shouldn't eat breakfast at that time, but actually I ate and regret it now.)
Incidentally, んだ/んじゃない as a strong command can be used only for second person, similarly, んじゃなかった is only for the speaker's regret.