Preheat oven to 375°F (190°C) and grease a 9x13 inch baking dish with butter or non-stick spray.
In a large saucepan, melt butter over medium heat. Add diced onion and sauté for 5 minutes until translucent and soft.
Add the minced garlic and fresh thyme to the pan; cook for 1 minute until fragrant.
Whisk in the flour and cook for 2 minutes, stirring constantly to create a light roux without browning.
Gradually whisk in the whole milk and heavy cream. Continue whisking over medium heat until the sauce reaches a gentle simmer and thickens enough to coat the back of a spoon (about 5-8 minutes).
Remove the sauce from heat. Stir in the salt, pepper, nutmeg, and 0.5 cup of the Gruyère cheese until fully melted and smooth.
Arrange half of the potato slices in the prepared baking dish in overlapping rows.
Pour half of the cheese sauce evenly over the first layer of potatoes.
Layer the remaining potatoes on top and pour the remaining sauce over them, pressing down gently with a spatula to ensure all potatoes are submerged.
Cover the dish tightly with aluminum foil and bake for 45 minutes.
Remove the foil and sprinkle the remaining 1 cup of Gruyère and the Parmesan cheese over the top.
Bake uncovered for an additional 30-35 minutes, or until the potatoes are fork-tender and the top is deep golden brown.
Remove from the oven and let the dish rest for 15-20 minutes to allow the sauce to set before serving.