Derbyshire built on a defiant last-wicket stand with six wickets to check Middlesex's progress with the bat on day two at Lord's.