Place butter and flour in food processor and pulse until it resembled breadcrumbs. You can also cut the butter in with a pastry cutter or two forks.
Stir in egg yolk and 1 tablespoon of water. The additional water can be used if the mixture doesn't seem to be coming together.
Form dough into a disc. Cover with plastic wrap and chill for 30-60 minutes.
Roll dough out onto a lightly floured surface until it around ¼ inch thick. Press into 9 inch pie or tart pan. Refrigerate for around one hour or freeze for around 20-30 minutes.
Preheat oven to 425° degrees F.
In a large skill heat butter over medium heat. Add onions and a pinch of salt. Cover and cook for 5-10 minutes. Cook and stir for 15-20 more minutes until carmelized.
Deglaze with water and scrape the pan with your spatula. Sprinkle in flour, milk, and salt and pepper. Cook for 1-2 more minutes.
Poke holes in dough and blind bake for around 10 minutes. Pour in filling.
Turn oven down to 350. Bake for 15-20 more minutes or until set.