darktable (and some other projects, like for example ufraw) don’t do any real lens detection or correction by itself. We depend on two libraries which in most cases are provided by the Linux distribution you’re using.
Lens Detection
Many image files contain metadata about how the image was created. In case of digital camera images, a standard called Exif is used, this standard allows a camera to record many details about how an image was taken. However Exif is not a singular well defined specification, there is a common part that is well defined, and there are the so-called MakerNotes. The MakerNotes are parts of Exif that each vendors gets to do with whatever they like. They are typically completely undocumented, and have to be reverse-engineered to be able to handle them in any way. For most vendors this reverse engineering has been done to some degree and at least parts of the MakerNotes can be deciphered most of the time.
This is a companion discussion topic for the original entry at https://www.darktable.org/2015/02/on-lens-detection-and-correction/