Heat olive oil in a large Dutch oven over medium-low heat. Add onions and a pinch of salt. Cook, stirring occasionally and adding small splashes of water, until deeply caramelized.
Remove onions and set aside.
In the same pot, cook bacon until crispy. Drain excess grease, leaving about 1 tablespoon.
Add onions back to the pot along with garlic. Cook until garlic is fragrant.
Pour in white wine and scrape the bottom of the pan.
Add pasta, beef broth, thyme, rosemary, and black pepper. Stir to toss everything evenly, working the pasta down into the broth in an even layer until mostly covered.
Bring pan liquid to a low simmering boil, cover, reduce heat to low, and cook until pasta is tender and most liquid is absorbed, about 10 minutes.
Stir in heavy cream and 1 cup Gruyère until melted.
Top with remaining Gruyère and Parmesan.
Cover with the pan lid to melt or place the pan under the broiler until cheese layer is bubbly and golden.