Hey @GyrosGeier any idea why nvidia-kernel-dkms (on trixie at least) does not depend on linux-headers-$arch?

The end result of installing it without kernel headers is that the driver doesn't work, because it can't compile without the headers. I can't think of any situation in which this is a desirable state

@azonenberg linux-headers-$arch is not necessarily correct, it just happens to be on amd64 desktop machines.

There has been a proposal for conditional dependencies, where linux-image-* would depend on linux-headers-* when dkms is installed.

We could maybe fake this with a negative dependency, like a "no-dkms" package that conflicts with dkms, and making linux-image-* depend on linux-headers-* | no-dkms, but only @juliank knows what the apt resolver would do with that. :P

@GyrosGeier @juliank well i was simplifying, i assumed in reality it would be a "kernel headers" metapackage provided by any of several different header packages depending on which image you had.

@azonenberg @juliank exactly, there is no way to encode "depending on which image you had" as a resolvable dependency except by forcing everyone to install kernel headers, even if they're not compiling modules.

I think that also pulls in the specific version of the C compiler that needs to be used, so it would make the compiler mandatory even for people not using out-of-tree modules.

@GyrosGeier @juliank my thought was something like, for example

linux-image-amd64: unchanged
linux-headers-amd64: provides linux-headers
linux-image-arm64: unchanged
linux-headers-arm64: provides linux-headers

nvidia-driver-dkms: depends on linux-headers

then if you try to install nvidia-driver-dkms you would have to install a linux-headers-* package for it to work, but you'd have to explicitly pick one of them (I think). This won't save you from installing arm headers on an amd64 machine or something but at least "complain if headers are missing" would be better than the current situation

alternatively maybe have update-initramfs complain at run time if DKMS is installed and there is a module that wants to build, but there's no headers/compiler for it to do so?

@azonenberg @juliank there's also linux-headers-cloud-amd64, and linux-headers-rt-amd64 on amd64, and linux-headers-ppc64el-64k on ppc64el, and...

So it's not "take the ones for the current architecture", but "install exactly those matching all installed kernels, and have those pull in the correct gcc version."

E.g. if I have 6.12 and 6.19 kernel images installed, then installing headers would need to pull in gcc-14 and gcc-15, and the only way to do that is to make the headers depend on gcc. If I also make the image depend on the headers, then the kernel image transitively depends on gcc, which warms my greybeard Unix admin heart but is not desirable for the majority of users.

@GyrosGeier @juliank yeah my thought was that any of those packages would provide linux-headers and dkms would simply complain or refuse to install if linux-headers was missing.

But as a minimum i'd like to see a runtime check if i install or update a kernel or package that would cause a DKMS compile, but I'm missing something, there should be a clearly visible stderr message and maybe even an exit code from the post-install script

@GyrosGeier @juliank automatically installing the correct package is a much harder problem, complaining if none are present is the far easier option
@azonenberg not from a user support perspective -- a lot of people don't even see stderr, and making the install process fail can skip the bootloader update and make the system unbootable.