Heat olive oil in a large pot over medium heat.
Add sliced onions and a pinch of salt. Sauté for 15-20 minutes, stirring occasionally, until caramelized.
Stir in minced garlic, thyme, and red pepper flakes, cooking for another 1-2 minutes until fragrant.
Pour in the vegetable broth, scraping up any browned bits from the bottom of the pot.
Add the pasta, stirring to combine, then cover and bring to a boil. Reduce heat to a simmer and cook according to pasta package instructions.
Once pasta is al dente, remove from heat and stir in grated Gruyère until melted and creamy.
Season with salt and pepper to taste, adjusting flavors as needed.
Serve immediately, garnished with additional cheese or fresh herbs if desired.