Boil macaroni in salted water according to package directions. Once cooked, drain the macaroni and place back into the pot, leaving it off the heat to cool down.
Melt butter in a skillet over medium heat. Add onions, cook until softened and slightly caramelized. Scrape the onions and melted butter into the pot with the macaroni. Stir to combine.
In a large bowl, beat eggs until fluffy. Add milk, salt, pepper, garlic powder, dry mustard, dried thyme and cayenne pepper. Stir to combine.
Pour the egg mixture over the macaroni and stir until well coated.
Stir in 3 cups of the shredded cheese.
Pour into the greased baking dish and top with reserved ½ cup of shredded cheese.
Bake until the pie is firm, and the top is golden brown. About 35-40 minutes.
Allow pie to rest for 10-15 minutes before serving.
I used a 9" x 11" enamelled cast iron baking dish to test this recipe. If you don't have that size, a 10" x 10" baking dish will also work. You can use a standard 9" x 13" baking dish, but your pie may turn out a little bit thinner than mine.Tips
Cold cheese is easier to shred than warm cheese
This dish is traditionally made with Trinidad-style cheese (New Zealand cheddar) but you can use any cheddar you like, or use a mixture of cheddar and mozzarella.
Aged cheddar will taste more "cheesy" than a mild cheddar
If the cheese on top begins to brown too quickly, cover it with tin foil for the remaining baking time.