Preheat your oven to 425°F (220°C).
Lightly grease a baking dish.
In a large pot over medium heat, melt butter.
Add onions and cook until they are soft and translucent, about 5 minutes.
Add garlic, salt, and pepper to the pot and cook for about 30 seconds.
Pour in the chicken stock and heavy cream.
Add the sliced potatoes and nutmeg.
Bring the mixture to a low simmer but do not boil.
Cover and reduce heat to medium-low.
Simmer for about 15 to 20 minutes until potatoes are nearly tender.
Layer half of the potato mixture into the greased baking dish.
Sprinkle half of the shredded cheddar cheese.
Add the remaining potato mixture and top with the rest of the cheese.
Bake in the preheated oven for about 20 to 25 minutes, until the cheese is bubbly and lightly golden brown on top.