01 -
Melt 2 tablespoons unsalted butter in a large skillet over medium-low heat. Add sliced onions and 1/2 teaspoon of salt. Cook, stirring occasionally, until onions are caramelized and deep golden, 30 to 40 minutes. Remove from heat and set aside.
02 -
Place bacon in a cold large skillet. Set over medium heat and cook until crisp, turning as needed, about 8-10 minutes. Transfer to a paper towel–lined plate, cool, and crumble. Reserve 1 tablespoon bacon fat for later use.
03 -
In a heavy saucepan, melt the remaining 4 tablespoons butter over medium heat. Add flour and whisk constantly to form a pale roux, about 2 minutes. Gradually add milk, whisking constantly to prevent lumps. Season with remaining salt, pepper, and nutmeg. Reduce heat to low and cook, stirring often, until thickened and smooth, 5 to 7 minutes. Remove from heat and fold in half of the cheddar and Gruyère until melted.
04 -
Preheat oven to 375°F (190°C). Lightly grease a 9x13-inch baking dish. Layer one third of potatoes in an even layer, season lightly with salt and pepper, and top with one third each of caramelized onions, crumbled bacon, and remaining cheeses. Repeat for two more layers. Strain and pour warm sauce evenly over the final layer. Tap dish gently to allow sauce to settle between layers.
05 -
Cover baking dish tightly with aluminum foil. Bake for 45 minutes. Remove foil and continue baking until potatoes are tender and the top is golden and bubbling, about 25–30 minutes more.
06 -
Let casserole rest for at least 15 minutes before serving to allow sauce to set. Sprinkle with fresh thyme if desired before serving.