Start by making the pastry. In a mixing bowl, combine the flour and salt. Add the chilled, diced butter and work it into the flour with your fingers until the mixture resembles coarse breadcrumbs. Gradually add ice water, stirring until the dough comes together. Form into a disc, wrap in plastic, and chill for at least 30 minutes.
Preheat your oven to 375°F (190°C). On a floured surface, roll out the chilled dough into a 12-inch circle. Press the dough into a 9-inch tart pan, trimming any excess. Prick the bottom with a fork and set aside.
For the filling, heat olive oil in a large skillet over medium heat. Add the sliced onions, sugar, salt, and pepper. Cook, stirring occasionally, until onions are deeply caramelized, about 30-40 minutes. Remove from heat and let cool slightly.
Sprinkle half of the shredded Gruyere cheese onto the bottom of the tart shell. Spread the caramelized onions over the cheese.
In a bowl, whisk together the eggs, heavy cream, and thyme. Pour this mixture over the onions. Top with the remaining Gruyere cheese.
Bake the tart for 25-30 minutes, or until the filling is set and the top is golden brown. Let it cool for a few minutes before serving.