Cook the pasta according to package instructions until al dente. Drain and set aside.
In a large skillet, melt butter over medium heat.
Add sliced onions to the skillet and cook until caramelized, about 15 minutes.
Stir in thyme, salt, and pepper.
Pour in beef broth and let simmer for 5 minutes.
Add heavy cream and mix well.
Incorporate the cooked pasta into the sauce, stirring to coat.
Sprinkle half of the Gruyère cheese over the pasta and mix.
Transfer the mixture to a baking dish and top with remaining cheese.
Bake in a preheated oven at 350°F (175°C) until the cheese is bubbly and golden, about 10 minutes.