Sift the flour and salt into a bowl and rub in the butter until it resembles breadcrumbs.
Mix in two tablespoons of water to form a dough, then chill for 30 minutes.
Preheat the oven to 180°C.
Cook the onions in butter with salt for 20-30 minutes until golden, then stir in thyme.
Roll the pastry, line a 23cm tin, and blind bake for 10 minutes.
Brush the pastry with egg and bake for another 5 minutes.
Combine the onions, cream, remaining egg, and seasoning, then pour into the case.
Bake for 30-35 minutes until the filling is set with a slight wobble.
Cool for 10 minutes before slicing and serving.