Grease a large baking dish with butter.
In a large skillet, melt the butter over medium-low heat, and sauté the onions with some seasoning, stirring regularly, until lightly colored (around 10 minutes). Transfer the onions to a bowl.
Use the same skillet to pan fry the bacon for 3 minutes (no extra fat needed) until crisp and light brown, then drain on some paper towels.
Drain and pat dry the potatoes and place them into a large bowl. Drizzle with the olive oil, season and add a few pinches of nutmeg. Mix in the bacon and onions to distribute evenly through the potatoes.
Add the garlic, bay leaf and thyme to the baking dish. Fill the dish with the potato mixture and pour the warm stock over. Place the dish in the oven (the oven should not be preheated) and set the temperature to 375°F (190°C). Cook, loosely covered with parchment paper, for 1 hour, then remove the parchment paper and cook for 15 minutes, or until most of the liquid is absorbed and the potatoes are crisp on top. Let it stand for 20 minutes before serving.