In a large skillet over medium high heat, melt the butter and add the onion and thyme, stirring briefly to coat with butter. Allow onion to cook, without stirring, until it starts to get dark brown, then add a pinch of salt and stir occasionally until onion is tender and caramelized, about 30 minutes total.
tir in swiss chard and cook until tender, about 5 minutes. Then transfer mixture to a large bowl.
To make spaetzle, combine flour, nutmeg, and a teaspoon of salt in a large bowl. In a separate bowl, whisk together eggs and milk. Make a well in the dry ingredients and pour in egg mixture. Mix well with a wooden spoon.
Fill a large bowl with ice water. Place dough in a spaetzle maker over a large pot of boiling salted water. Shave dough into the water (alternatively, push dough through a colander into the water). When dumplings rise to surface, use a slotted spoon to transfer them to the ice water.
Preheat oven to 375 degrees. Drain spaetzle well and transfer to bowl with onions and greens. Sprinkle in three fourths of the cheese and mix well.
Scrape the spaetzle mixture into a 2 quart gratin dish. Sprinkle on remaining cheese and bake for 25 to 30 minutes, until top is golden brown and bubbling.