Make the filling: Place the potatoes in a saucepan, cover with cold water, and add a generous pinch of salt. Bring to a boil, then reduce to a steady simmer and cook for 12 to 15 minutes, or until very tender. Drain well and return the potatoes to the warm pan for 1 minute to let excess moisture evaporate.
Mash the potatoes until smooth. Stir in the farmer cheese, melted butter, salt, and pepper. Taste and adjust the seasoning if needed. Spread the filling on a plate or shallow bowl and let it cool until no longer warm.
Make the dough: In a large bowl, whisk together the flour and salt. Make a well in the center, then add the egg and warm water. Stir with a fork until a shaggy dough forms. Turn it onto a lightly floured surface and knead for 4 to 5 minutes, until smooth and soft. Cover the dough with the bowl or a clean towel and let it rest for 20 minutes.
While the dough rests, make the onion topping. Melt the butter in a skillet over medium-low heat. Add the onion and cook, stirring occasionally, for 12 to 15 minutes, until soft, golden, and lightly caramelized. Keep warm over low heat.
Divide the rested dough in half. Keep one half covered while rolling the other half on a lightly floured surface to about 1/8 inch (3 mm) thick. Cut into 3-inch (7.5 cm) rounds using a cookie cutter or drinking glass. Gather and reroll the scraps as needed.
Place about 1 tablespoon (15 ml) of cooled filling in the center of each round. Fold the dough over the filling to form a half-moon. Press out any trapped air, then firmly pinch the edges closed. Place finished varenyky on a lightly floured baking sheet and cover them with a towel while shaping the rest.
Bring a large pot of generously salted water to a gentle boil. Cook the varenyky in batches so the pot is not crowded. Stir gently once after adding them. When they float, cook for 2 to 3 minutes longer, then lift them out with a slotted spoon.
Serve the hot varenyky topped with the buttery onions. Add sour cream and fresh dill, if desired.