Preheat your oven to 180°C (350°F).
Cook the pasta in salted boiling water until just al dente, about 8 minutes. Drain and set aside.
Melt 2 tablespoons of butter in a large skillet over medium heat. Add diced onion and sauté until translucent, about 5 minutes, until it smells sweet and the onion looks glossy.
Stir in pumpkin puree, heavy cream, and spices (nutmeg, cinnamon, paprika). Let simmer gently, stirring occasionally, until heated through and fragrant, about 5 minutes.
In a small saucepan, melt remaining 2 tablespoons of butter over medium heat. Whisk in flour and cook, stirring constantly, for about 2 minutes until the mixture turns a light golden color.
Gradually pour in the milk, whisking constantly to prevent lumps. Continue cooking until the sauce thickens and coats the back of a spoon, approximately 5 minutes.
Combine the pumpkin sauce with the cooked pasta, stirring well to coat evenly. Transfer everything to a greased baking dish.
Sprinkle the shredded cheddar cheese (and Gruyère if using) evenly over the top of the pasta mixture.
Bake in the preheated oven until bubbling and golden on top, about 15-20 minutes. The cheese should be melted and slightly crisp around the edges.
Remove from oven and let sit for a few minutes to settle. Serve hot, with steam rising and a rich, cheesy aroma filling the air.