Custom kernel expression stuck at ati drivers

This is the expression I use for now.
With it I can

  • nix-shell default.nix -A kernel to have the dependencies for running make menuconfig
  • run make KCONFIG_CONFIG=source/Microsoft/config-wsl menuconfig -C source in above nix-shell to configure kernel build based on configuration provided with kernel linux-msft-wsl-5.10.102.1
  • when ready editing configuration save as source/Microsoft/config-wsl-usb in menuconfig or use edited configuration in configfile below
  • i. e. nix repl and therein :l default.nix (file attached to this post) and :b kernel
  • run nix-store --read-log /nix/store/*** to inspect the logs of the built derivation accordingly replacing *** with output of step beyond (or equivalent nix log /nix/store/***)
Click for listing of the kernel builder expression
# default.nix
# try 
# 1) nix-shell default.nix -A kernel
# 2) Therein make KCONFIG_CONFIG=source/Microsoft/config-wsl menuconfig -C source using the config default 
# 3) When ready editing config save as source/Microsoft/config-wsl-usb or use your value in configfile below
# 4) I. e. nix repl and therein :l default.nix :b kernel
# 5) nix-store --read-log /nix/store/*** # to inspect the logs of the built derivation replacing *** or just
# 6)  nix log /nix/store***
# borrowed here https://sourcegraph.com/github.com/tpwrules/nixos-m1/-/blob/nix/m1-support/kernel/package.nix
{ pkgs ? import <nixpkgs> {
overlays = [
   (_: prev: {
     buildLinux = kernel: (prev.buildLinux kernel).overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ prev.pkg-config prev.ncurses ];});
     linuxPackagesFor = kernel: (prev.linuxPackagesFor kernel).extend (_: _: {
        ati_drivers_x11 = null;
      });
   })
];
}}: let

          
    # manualConfig is basically buildLinux, see https://github.com/NixOS/nixpkgs/blob/a26c5e5c43c36267643dc48458f5ffd61a478a1a/pkgs/top-level/all-packages.nix#L11630
    linux_wsl_pkg =  { stdenv, lib, fetchurl, fetchFromGitHub, fetchpatch, linuxKernel, buildLinux, version, src, ... } @ args:

      buildLinux (args // rec {
          version = "5.10.102.1";
	  src = fetchTarball {
            url = "https://github.com/microsoft/WSL2-Linux-Kernel/tarball/linux-msft-wsl-${version}";
            sha256 = "18b5s6kxjnxnfhhh5ywgnxrj4pi8jr0g0bdd9y3vj7qi1q2nz7zw";
          };
          modDirVersion = version;

          kernelPatches = [];

          # source: https://sourcegraph.com/search?q=context:global+file:.*%5C.nix+%28content:%22structuredExtraConfig%22+AND+content:%22%28_:+value:+lib.mkForce+value%29%22%29&patternType=literal
          structuredExtraConfig = with pkgs.lib.kernel; builtins.mapAttrs (_: value: lib.mkForce value) {
            USB_AC = yes;
            USBIP_CORE = yes;
            USBIP_VHCI_HCD = yes;
            USBIP_VHCI_HC_PORTS = freeform "8";
            USBIP_VHCI_NR_HCS = freeform "1";
            USBIP_DEBUG = yes;
            USB_SERIAL = yes;
         };

        ignoreConfigErrors = true;
        autoModules = false;
        kernelPreferBuiltin = true;
        enableParallelBuilding = true;

          extraMeta.branch = "5.10";
        } // (args.argsOverride or {}));

      linux_wsl = pkgs.callPackage linux_wsl_pkg rec {
          inherit (linux_wsl_pkg) version src structuredExtraConfig;
          allowImportFromDerivation = true;
          # when running manual kernel config use file I saved here i. e. ./source/Microsoft/config-wsl-usb
          configfile = ./source/Microsoft/config-wsl;
      };
    in  pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_wsl)

Open question: Still would be good to know if just the default config could be used here combined with extraConfig to reliably do without the (interactive) menuconfig step, i. e. extraConfig just modifying what default kernel configuration is serving already. Follow up question then: When would I need SETTING = lib.mkForce yes; ?
I would like to answer this myself as well: See the edits in the above kernel builder expression. Correctly applying structuredExtraConfig seems to lead to (excerpt on an already manually edited configuration - hence the y all over there) this output when nix-shell default.nix -A kernel is first run:

QUESTION: USB/IP support, NAME: USBIP_CORE, ALTS: N/m/y/?, ANSWER: y
GOT: y
QUESTION: VHCI hcd, NAME: USBIP_VHCI_HCD, ALTS: N/m/y/?, ANSWER: y
GOT: y
QUESTION: Number of ports per USB/IP virtual host controller, NAME: USBIP_VHCI_HC_PORTS, ALTS: 8, ANSWER: 8
GOT: 8
QUESTION: Number of USB/IP virtual host controllers, NAME: USBIP_VHCI_NR_HCS, ALTS: 1, ANSWER: 1
GOT: 1
QUESTION: Host driver, NAME: USBIP_HOST, ALTS: N/m/y/?, ANSWER:
GOT:
QUESTION: Debug messages for USB/IP, NAME: USBIP_DEBUG, ALTS: N/y/?, ANSWER: y
GOT: y

So I dare saying success.

EDIT: Removed the extraStructuredConfig related stuff as it was misleading and extraStructuredConfig belongs to and only to the kernelPatches closure.

EDIT: WSL2 doesn’t seem to like bzImage so I figured the vmlinuz location.

nix-repl> kernel.dev.outPath