Preheat oven to 350°F (175°C). Cut bread into 1-inch cubes and spread on a baking sheet. Bake for 10-12 minutes until dry and lightly toasted. Leave oven on.
In a large bowl, whisk eggs until frothy. Add milk, cream, broth, salt, pepper, nutmeg, and Dijon mustard. Whisk until fully combined. Set aside.
Heat 1 tablespoon olive oil and 1 tablespoon butter in a large skillet over medium-high heat. Add half the mushrooms in a single layer. Cook undisturbed for 4-5 minutes until browned, then flip and cook 2-3 minutes more. Transfer to a plate and repeat with remaining mushrooms.
In the same skillet, add remaining butter. Cook shallots for 3-4 minutes until soft. Add garlic and cook 60 seconds until fragrant. Stir in thyme, rosemary, and red pepper flakes. Add spinach and cook 1-2 minutes until wilted. Set aside with mushrooms.
In a large bowl, combine toasted bread cubes, cooked mushrooms, shallot-spinach mixture, and 1 cup of grated Gruyère. Fold in pancetta if using. Toss gently to distribute evenly.
Butter the baking dish. Transfer the bread mixture to the dish and spread evenly. Whisk custard again and pour slowly over the bread, pressing down gently to help absorption. Sprinkle remaining ½ cup Gruyère on top. Let rest for 20 minutes at room temperature.
Cover tightly with foil and bake for 30 minutes. Remove foil and bake uncovered for 20-25 minutes more until golden brown and set. The center should spring back when pressed. Broil for 2-3 minutes for extra crispness, if desired.
Rest for 10 minutes before cutting. Garnish with fresh parsley. Serve warm from the baking dish.