Preheat oven to 375°F. Grease an 8x8-inch baking dish.
Melt butter in a large skillet over medium heat. Add onions, sprinkle with salt and pepper, and cook until tender, about 8 minutes. Cover, reduce heat to low, and continue to cook, stirring every 5 minutes, until very soft, another 20 minutes. Remove from heat and set aside.
Boil pasta in salted water according to package directions. Drain completely and set aside.
In a large bowl, whisk together cheese or cream, eggs, poppy seeds, and nutmeg. Season with salt and pepper, add onions and pasta and stir in. Transfer to prepared baking pan, and sprinkle with grated cheese. Cover loosely with baking parchment.
Bake 30 minutes, or until set, then remove parchment and continue to bake 15 to 20 minutes or until the top is golden brown.
Remove from oven and let stand 10-15 minutes before slicing and serving.