Derbyshire 338 for 9 (Godleman 51, Reece 51, Wiese 4-63, Garton 3-79) and 31 for 1 lead Sussex 271 (Wright 70*, Viljoen 7-80) by 98 runs
South African Hardus Viljoen returned the best figures by a Derbyshire bowler for two years to put his side in a good position against Sussex at Hove.
Viljoen took 7 for 80 with four of his victims clean bowled as Sussex, who need to win to maintain their promotion challenge in the Specsavers County Championship, were bowled out for 271 and conceded a first-innings deficit of 67.
In a final session truncated by heavy showers, Derbyshire extended their lead to 98 although they did lose Luis Reece, well caught at second slip by Chris Nash off Jofra Archer, before they closed on 31 for 1.
Viljoen is in his first season with Derbyshire after signing as a Kolpak but his summer has been hampered by knee and groin injuries. However, the 28-year-old, who removed England's Alastair Cook with his first ball in his only Test appearance in 2016, looked the part here, bowling with pace and aggression with four of his wickets coming during a 12-over spell either side of lunch.
Luke Wright, Sussex's former captain, said: "As a team we've had two bad days if we're being honest. But you get more chances in the second division and we'll be looking to knock them over tomorrow and then chase a target on the last day on a pitch which is pretty good.
"Viljoen is a big strapping lad and bowls fast. He seems to get in and out of rhythm but when he gets it right he can get it through. But we should have seen off his threat better."
Sussex would have been in worse trouble had Wright, who finished unbeaten on 70, and David Wiese not put on 80 for the eighth wicket after they had slumped from 62 for 1 to 149 for 7 and looked in danger of being asked to follow on.
Angus Robson fell to Harry Podmore in the Middlesex loanee's first over but Luke Wells (46) and Stiaan van Zyl (17) looked reasonably comfortable in adding 61 for the second wicket before Viljoen returned to the attack. Van Zyl and Chris Nash (20) both played on and Wells (46) was beaten by one which seamed late at pace in the final over before lunch.
Ben Brown (23) was surprised by extra bounce and Viljoen had his second five-wicket haul of the season when Archer spliced an attempted pull to mid-on.
But when Viljoen had a breather, Wright and Wiese took advantage with a sensible partnership which was ended by 16-year-old off-spinner Hamidullah Qadri, who had Wiese well taken by keeper Harvey Hosein as he pushed forward for 47.
Wright went past 50 for only the fourth time this season and hit eight fours, but he was left high and dry at the other end when Viljoen returned after tea to end the innings with successive balls as George Garton was caught behind and Derby-born Stuart Whittingham lost his off stump.
It was the first time a Derbyshire bowler had taken seven wickets at Hove since Geoff Miller in 1977 and they were the best figures by a non-English bowler for the county since Ian Bishop took 7 for 34 against Hampshire at Portsmouth in 1992.
Earlier, Derbyshire's first innings had ended when Archer bowled Hosein for 38 with the first ball of the day.