in 1840, the north midland railway set up its works in derby and, when it merged with the midland counties railway and the birmingham and derby junction railway, to form the midland railway, derby became its headquarters.