Where does the "required modules" list come from?

Trying to build NixOS with a custom monolithic kernel image (CONFIG_MODULES=n) and I get this error:

building '/nix/store/5hi8i35k6nhgp4zn2hj4psk02qgf2lcs-linux-6.12.87-modules-shrunk.drv'...
linux> Required modules: ahci ata_piix atkbd autofs crc32c efivarfs ehci_hcd ehci_pci hid_apple hid_cherry hid_corsair hid_generic hid_lenovo hid_logitech_dj hid_logitech_hidpp hid_microsoft hid_roccat i8042 mmc_block nvme ohci_hcd ohci_pci pata_marvell pcips2 sata_nv sata_sis sata_uli sata_via sd_mod sr_mod tpm-crb tpm-tis uhci_hcd usbhid xfs xhci_hcd xhci_pci dm_mod
linux> Can not derive a closure of kernel modules because no modules were provided.
error: builder for '/nix/store/5hi8i35k6nhgp4zn2hj4psk02qgf2lcs-linux-6.12.87-modules-shrunk.drv' failed with exit code 1;

Some of the things in the “required modules” list are compiled into the monolith, but the majority are unnecessary (e.g. this is a cloud VM, it does not have any of those HID devices). How is this list computed and how do I educate it about the things that are compiled into the kernel and the things that aren’t actually necessary?

For reference, this is the NixOS module building the custom kernel:

{ lib, pkgs, ... }:
{
  boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linuxManualConfig {
    inherit (pkgs.linuxKernel.packageAliases.linux_default.kernel)
      src version modDirVersion;
    configfile = ./minimal-x86-kvm-guest.kconf;
  });
}

minimal-x86-kvm-guest.kconf will be supplied on request but, despite my strenuous efforts to turn off as much as possible, it’s 3000 lines long, with ~1000 active CONFIG_* lines, so hopefully you don’t need it :wink: