01 - Preheat the oven to 350°F. Grease a 9x13-inch baking dish with butter or nonstick spray.
02 - Melt butter in a medium saucepan over medium heat. Add the chopped onion and cook until soft and translucent, about 3 to 4 minutes.
03 - Stir in flour and cook for 1 minute while stirring constantly to create a roux.
04 - Gradually whisk in whole milk and heavy cream. Continue cooking and stirring until the sauce thickens, approximately 5 minutes.
05 - Remove from heat and stir in Dijon mustard, salt, black pepper, and nutmeg. Fold in shredded cheddar and Gruyère until melted and smooth.
06 - Arrange half of the sliced potatoes evenly in the prepared baking dish. Pour half of the cheese sauce over the potatoes. Repeat the layers with the remaining potatoes and cheese sauce.
07 - Sprinkle the remaining shredded cheddar and Gruyère cheeses evenly over the top.
08 - Cover the dish with foil and bake for 40 minutes.
09 - Remove foil and bake an additional 20 minutes until the top is golden and potatoes are tender when pierced.
10 - Let the dish rest for 10 to 15 minutes before serving. Garnish with fresh chives or parsley if desired.