1. In a large frying pan over high heat, cook onions in 3 tbsp. olive oil with sugar and 2 tsp. salt, stirring and turning often, until onions begin to release their juices and turn golden, 10 to 13 minutes. Reduce heat to medium and cook, stirring occasionally, until onions turn a caramel color and become quite sweet, 35 to 40 minutes more. If onions begin to stick to the pan or char during cooking, reduce heat.
2. Meanwhile, in a small frying pan (not nonstick) over medium-low heat, toast walnuts, stirring frequently, until fragrant and golden, about 10 minutes. Remove from heat and cool slightly. Pour walnuts into a zip-lock plastic bag and lightly crush with a rolling pin. Set aside.
3. When onions are nearly done, cook pasta in boiling salted water until tender to the bite, 9 to 12 minutes or according to package instructions. Drain pasta, reserving about 1/2 cup cooking water.
4. Toss caramelized onions with pasta, walnuts, ricotta salata, parsley, reserved cooking water, lemon juice, pepper, and remaining 2 tbsp. olive oil. Season to taste with salt. Serve hot.
Note: Nutritional analysis is per serving.