[[https://github.com/dell/dkms][Dynamic kernel module support]] (DKMS) is a feature that allows installation of kernel modules while reinstalling the kernel.
This is preferable if you don't want to build and install kernel modules every kernel update.
Oftentimes to build the kernel module, it is required to install Linux-related headers.
Here's an example scenario where I want to install [[https://github.com/jlam55555/veikk-linux-driver/issues/43][Veikk tablet driver]] that is not available out-of-the-box.
The following list is the summarized version of what should happen.
- Download the source code of the kernel module.
- Check if the Linux headers are available otherwise the kernel module cannot be built.
- Place the kernel module source into the kernel source tree (e.g., =/usr/src=).
- Create =dkms.conf= to tell where the module is to be built.
- Install the module with ~dkms~.
The most difficult out of the steps is configuring with =dkms.conf=.
You can see the format and the available options from =dkms.8= manual page.
For now, let's see the example configuration.
#+begin_src shell :results silent
PACKAGE_NAME="input-veikk"
PACKAGE_VERSION="git"
BUILT_MODULE_NAME[0]="veikk" # (ref:module-name)
DEST_MODULE_LOCATION[0]="/extra/"
AUTOINSTALL="yes"
#+end_src
This tells ~dkms~ to install the Veikk driver, packaged as =input-veikk= with version =git=, in =extra/= (e.g., =/lib/modules/@LINUX_KERNEL_VERSION@/extra=).
When installed, you should see a module named [[(module-name)][=veikk=]] — e.g., see the module list with =lsmod=.
With the setup complete, run ~dkms install -m input-veikk -v git~ and it should be effective immediately.