Finely dice the onion and sauté in a saucepan with margarine. Dust with the flour and deglaze with cream while stirring. Boil. Dilute with milk if the sauce gets too thick. The sauce should still be slightly thick.
Then season with salt, nutmeg and the instant powder. Let simmer gently. Add the diced ham and the drained peas.
Whisk the yolks and eggs together well. Stir the cheese into the sauce. Remove from heat and then stir in the egg mixture.
Drain the cooked spaghetti and put it back in the saucepan, add the sauce and mix everything together well. Serve immediately.