Grease an 8 inch square baking dish and spread the cubed bread in the bottom. Heat 1 tablespoon of the olive oil in a skillet over medium low heat. Add the onions,salt, and sugar. Saute until lightly caramelized, about 15 minutes.
Meanwhile, in another skillet, heat the other tablespoon of olive oil over medium heat and saute bacon until the fat is almost all rendered and it begins to get crisp, about 8 to 10 minutes. Set on a paper towel to drain.
Whisk the eggs, milk dry mustard, nutmeg and thyme. Season with about 1/4 teaspoon of salt and a generous quantity of black pepper.
Spread the bacon over the bread cubes, then layer the onions on top. Sprinkle grated Gruyere on next, then pour the egg mixture over the entire thing.
Press down on top gently, so that all of the bread cubes get soaked a bit with the egg mixture. Cover and refrigerate overnight.
In the morning, preheat the oven to 350 degrees F and take the casserole out of the fridge while the oven is preheating. Bake, uncovered, for 35 to 50 minutes or until the edges are bubbling and the top begins to brown.(cover with foil near the end if the top is already browned.)