To make the pastry, sift the flour into a large bowl, then stir in the mustard powder, cayenne and 1 tsp salt. Grate the butter into the flour, dipping the end of the block in flour from time to time to prevent it from clumping. Stir the flour and butter together using a table knife, then pour in 120ml ice cold water, mix and bring together to form a dough. Flatten the dough into a disc, wrap in cling film and chill in the fridge for 1 hour.
Meanwhile, make the filling. Cook the potatoes in a pan of salted water until tender, then drain and steam dry for a few mins before mashing and leaving to cool. Melt the butter in a frying pan until foaming. Add the onions and a pinch of salt, and cook, stirring occasionally, over a medium heat until they’re completely soft and starting to caramelise. Add to a bowl with the potato. Once cool, stir in the thyme leaves, mustard, cheese and gherkins or pickled onions, and season to taste. Set aside.
Line a baking tray with baking parchment. On a lightly floured surface, roll the pastry out into a large rectangle around 3mm thick. Cut the pastry into eight rectangles, then divide the filling equally between them, squashing it into a sausage shape down the long length of one side of each rectangle, leaving a 5cm gap at each end. Brush the exposed pastry with a little egg, then fold in the short sides of the rectangle and roll the empty half of pastry over the filling so that it is completely encased. Press the edge to seal it, then crimp the two shorter ends with a fork. Repeat with each roll, then transfer to the lined baking tray and chill in the fridge for 20 mins. Can be frozen at this point.
Heat oven to 200C/180C fan/gas 6. Take the rolls out of the fridge, brush all over with the beaten egg, then scatter with the nigella seeds. Bake on the top shelf of the oven for 40 mins or until deeply golden and crisp. Serve hot or cold with your choice of sauce.