1.Cook the elbow macaroni according to package instructions; drain and set aside.
2.Slice the onions thinly and cook them in butter over medium heat until caramelized.
3.Add the beef broth and scrape the bottom of the pan to deglaze. Let it simmer for 10 minutes.
4.Stir in heavy cream, salt, pepper, and thyme.
5.Add the cooked macaroni to the onion mixture and stir well.
6.In a baking dish, layer the macaroni mixture and top with grated gruyère cheese.
7.Bake in the oven at 180°C (350°F) until the cheese is bubbly and golden brown.