Preheat the oven to 375°F and butter an 8-cup ovenproof pie or casserole dish.
Melt the butter in a large saucepan over medium heat, add onions and garlic, and cook for 6 to 8 minutes until softened and translucent without browning. Remove from heat.
In a bowl, whisk together heavy cream, milk, Dijon mustard, nutmeg, salt, and black pepper.
Arrange half of the potato slices in the prepared dish with a slight overlap. Top with half of the onion mixture, then sprinkle with half the Gruyère and cheddar cheeses.
Repeat the layering with the remaining potato slices, onion mixture, and cheeses.
Pour the cream mixture evenly over the layers and gently press down with a spatula to compact.
Cover the dish with aluminum foil and bake for 40 minutes.
Remove the foil and bake for an additional 20 minutes until the top is golden and the filling is bubbling.
Allow the pie to rest for 10 minutes before serving. Garnish with fresh chives if desired.