1. In a large, deep skillet, melt 4 tablespoons of the butter.
2. Add the onion and cook over low heat, stirring occasionally, until softened but not browned, about 10 minutes.
3. Using a slotted spoon, transfer the onion to a bowl leaving as much of the butter in the pan as possible.
4. Add the mushrooms to the skillet, season with salt and pepper and cook over high heat, stirring occasionally, until the liquid is evaporated and the mushrooms are golden, about 8 minutes.
5. Stir in the shallot and garlic and cook for 1 minute.
6. Return the onion to the skillet.
7. Add the chicken stock and parsley and simmer over moderately high heat until the liquid is reduced to 1/4 cup, about 8 minutes.
8. Add the remaining 2 tablespoons of butter along with the pistachios, lemon juice (and red pepper flakes if desired) and stir until the butter is melted.
9. Season with salt and pepper.
10. Cook the pappardelle in a large pot of boiling salted water until al dente.
11. Drain the pasta, reserving 1/2 cup of the cooking water.
12. Add the pappardelle to the skillet along with the reserved cooking water and the olive oil.
13. Cook over moderately high heat, tossing, until the pasta is coated with a thick sauce, about 2 minutes.
14. Transfer the pasta to bowls, top with fresh grated cheese, serve immediately.