Preheat the oven to 350 degrees F. Butter an 8-ounce oval gratin dish.
Add the half-and-half, shallots, garlic, rosemary and nutmeg to a medium saucepan. Bring to a light simmer. Add the potatoes to the saucepan and simmer for 3 minutes; the potatoes should be just covered with the liquid. Once you see the liquid thicken a bit, remove and discard the thyme sprig.
Pour half of the potatoes into the prepared baking dish. Dot with 1 tablespoon butter and half the Gruyere. Pour in the rest of the potatoes and finish covering with Gruyere and Parmesan. Dot the potatoes with the last tablespoon of butter.
Cover with foil and bake for 40 minutes. Remove the foil and bake until golden and bubbly, 10 more minutes.