Change:
Describe the bug I am no longer able to build VirtualBox with guest additions when switching over to the lastest linux kernel: . The error complains that headers are missing/not found. This bug occurs consistently across all 3 of my machines. I am still able to build VirtualBox without guest additions. To Reproduce Here is the relevant snippet of my Additional context Here is the relevant errors from using Metadata Nix Info: Maintainer information:
Just hit the same thing myself too, very inconvenient to say the least.
Me too, is there any workaround?
No I never found a fix. In the end I had to remove VBox Guest.
It seems the only way to work around this is not to use boot.kernelPackages = pkgs.linuxPackages_latest;
Can you check whether this is still the case on the branch? I was able to build that with the same configuration as above:
I take that back - it's now failing at a later stage: This looks like we're missing a patch similar to the one in
agreed, that looks to be the exact same file that was patched in the host version of a VirtualBox. I did a quick search for an upstream bug for vboxguest but couldn't find anything. Perhaps it gets copied from the same source in the build process. I could try applying the same patch to vboxguest and alter the paths to see what happens. I won't have the opportunity to try that out until tonight (North America, west cost). So if you or someone else want to try it out sooner let me know.
Fix in , please test :-)

Discussion:
{ stdenv, fetchurl, lib, patchelf, cdrkit, kernel, which, makeWrapper <del> , zlib, xorg, dbus, virtualbox }: </del> <ins> , zlib, xorg, dbus, virtualbox, dos2unix }: </ins> let version = virtualbox.version;

KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include"; <del> # If you add a patch you probably need this. #patchFlags = [ "-p1" "-d" "install/src/vboxguest-${version}" ]; </del> hardeningDisable = [ "pic" ]; NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";

nativeBuildInputs = [ patchelf makeWrapper ]; buildInputs = [ cdrkit ] ++ kernel.moduleBuildDependencies; <del> postPatch = '' </del> <ins> prePatch = '' </ins> substituteInPlace src/vboxguest-${version}/vboxvideo/vbox_ttm.c  --replace "<ttm/" "<drm/ttm/" <ins> ${dos2unix}/bin/dos2unix src/vboxguest-${version}/vboxguest/r0drv/linux/mp-r0drv-linux.c </ins> ''; <ins> patchFlags = [ "-p1" "-d" "src/vboxguest-${version}" ]; # Kernel 5.3 fix, should be fixed with VirtualBox 6.0.14 # https://www.virtualbox.org/ticket/18911 patches = [ ./kernel-5.3-fix.patch ]; </ins> unpackPhase = '' ${if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then '' isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run

<ins> --- a/vboxguest/r0drv/linux/mp-r0drv-linux.c +++ a/vboxguest/r0drv/linux/mp-r0drv-linux.c @@ -283,12 +283,15 @@ if (RTCpuSetCount(&OnlineSet) > 1) { /* Fire the function on all other CPUs without waiting for completion. */ -# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) +# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) +        smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */); +# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */); +        Assert(!rc); NOREF(rc); # else int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* retry */, 0 /* wait */); -# endif Assert(!rc); NOREF(rc); +# endif } #endif @@ -326,7 +329,6 @@ { #ifdef CONFIG_SMP IPRT_LINUX_SAVE_EFL_AC(); -    int rc; RTMPARGS Args; RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; @@ -337,14 +339,17 @@ Args.cHits = 0; RTThreadPreemptDisable(&PreemptState); -# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) -    rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); +# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) +    smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); +# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) +    int rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); +    Assert(rc == 0); NOREF(rc); # else /* older kernels */ -    rc = smp_call_function(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); +    int rc = smp_call_function(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); +    Assert(rc == 0); NOREF(rc); # endif /* older kernels */ RTThreadPreemptRestore(&PreemptState); -    Assert(rc == 0); NOREF(rc); IPRT_LINUX_RESTORE_EFL_AC(); #else RT_NOREF(pfnWorker, pvUser1, pvUser2); </ins>