About an hour before you plan to make your pie crust, place the butter cubes in the freezer. The colder the butter, the better your chances of achieving a nice flaky crust.
Once your butter is sufficiently chilled – Place the flour, salt, and sugar in a food processor. I have one of those itty bitty ones for this purpose. Pulse about 5 times until flour, salt, and sugar are combined. Add the butter cubes and pulse until the mixture resembles coarse meal, about 10 pulses total. Add the gruyere and pulse about 5-6 more times. You should be left with quite a few pea size pieces of butter. And that is cool.
Remove ice from your water, if any – And add 2 tablespoons of water to the food processor and pulse 2-3 times. Add water 1 tablespoon at a time, pulsing with each addition. The mixture should just barely clump together at this point, yet have a crumbly look to it. Test by pinching some of the dough and if it comes together, then it’s ready to use. If not, keep adding one tablespoon of water at a time, giving it 2-3 pulses each time. I’ve made this crust many times and it’s never taken more than 4 tablespoons of water. Make sure you don’t add too much; otherwise your crust won’t be flaky.
Turn the crumbly dough over a lightly flour surface and gather it into a rough circle. Handle the dough as carefully as possible so as not to activate too much gluten which can toughen your pie crust. Your pie crust should be dotted with gorgeous pieces of butter and cheese.
Lightly sprinkle flour over surface of the dough. Cover the dough with plastic wrap and place in the refrigerator for at least one hour to chill. If using the dough another day, place in the freezer. When ready to use, defrost it in the refrigerator overnight. Dough keeps well in the freezer for about a month. While dough is chilling, caramelize the onions.