Preheat the oven to 400F.
Spread a thin layer of butter on a 10-inch diameter pie pan. Roll out the pie crust over it and press the bottom border to fit the pie crust.
Peel the onions and slice them thin by hand or with the help of a mandoline.
In a wide bottom pan, add two tablespoons of olive oil over medium-high heat. Add the onion slices and cook at medium heat for about 20 minutes, stirring once in a while. You want the onions to become translucent but not brown. Lower the heat if that happens.
Add the two tablespoons of flour over the onions, mix well, and continue cooking for about 2 more minutes. It will look and feel thicker consistency.
Add the heavy cream to the onion mixture. Mix well and cook at low heat for another 2 minutes.
In a bowl, whisk your eggs with salt, pepper, and nutmeg. Add the egg mixture to the onion mixture. Mix well until the eggs and onion mixture is well incorporated.
Drop the onion mixture into the pie crust. Smooth the top. Add the grated cheese over it, an optional step.
Place the pie dish over a cookie sheet. Place in the hot oven and bake for 20 minutes. Serve hot.