For the pastry, pulse the flour, baking powder, salt, butter and egg yolk in a food processor until the mixture resembles breadcrumbs. Add the grated parmesan and stir until well combined.
Gradually add the water, mixing until the mixture just comes together as a dough. Roll into a ball, wrap in cling film and chill in the fridge for an hour.
For the filling, boil the potato cubes until tender, then drain. Boil the sliced onions until softened, drain and return to pan.
Sprinkle onions with flour, add milk and cream, heat until thickened. Stir in potatoes, cheese, mustard and cayenne pepper. Season to taste.
Preheat the oven to 180C/350F/Gas.
Grease a pie tin with butter, dust with flour. Roll out two-thirds of the pastry and line the tin, prick the base. Bake with greaseproof paper and beans for 10-15 minutes until golden-brown. Cool and add filling.
Roll out remaining pastry for the lid, seal with crimping, make steam holes, brush with egg and bake for 25-30 minutes until golden-brown.