USB-C Docking Station Network during initrd (dhcp)

Hi there

I have a notebook that runs native root encrypted zfs. In my configuration.nix I have this snippet to enable remote unlocking:

    # Remote ZFS Unlock = {
        enable = true;
        ssh = {
            enable = true;
            port = 2222;
            hostECDSAKey = /root/initrd-ssh-key;
            authorizedKeys = [ "${mySecrets.auth_ssh_key1}" "${mySecrets.auth_ssh_key2}" ];
        postCommands = ''
            echo "zfs load-key -a; killall zfs" >> /root.profile
    boot.initrd.kernelModules = [ "r8169" ];

Now I got a usb-c docking station that can also supply networking but I’ve been unable to get the network up during dhcp.

I expanded the kernel modules line at first to:

    boot.initrd.kernelModules = [ "r8169" "cdc_ncm" "xhci_hcd" ];

That would include the usb 3.0 drivers (xhci_hcd) and the kernel module that shown after system boot up when I check the network:

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 1: Dev 3, If 5, Class=Communications, Driver=cdc_ncm, 5000M

       description: Ethernet interface
       physical id: 6
       logical name: enp0s20f0u1u1i5
       serial: 00:50:b6:b5:c8:a4
       capabilities: ethernet physical
       configuration: broadcast=yes driver=cdc_ncm driverversion=22-Aug-2005 firmware=CDC NCM ip= link=yes multicast=yes

However the initrd still only tries to bring up the eth0 interface:

According to nixpkgs/initrd-network.nix at edc033a6165f4bb8f64799e285edce16700d3d21 · NixOS/nixpkgs · GitHub it seems to try to load stuff that’s present there. Checking whether the usb network is also in there, I run

root@subi:~# ls -al /sys/class/net/enp0s20f0u1u1i5
lrwxrwxrwx 1 root root 0 Sep 15 18:21 /sys/class/net/enp0s20f0u1u1i5 -> ../../devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.1/2-1.1:1.5/net/enp0s20f0u1u1i5

So the usb network seems actually to use some usb2 drivers. Because of that I check which usb modules are actually loaded and so I expanded the initrd modules again to:

    boot.initrd.kernelModules = [ "r8169" "cdc_ncm" "xhci_hcd" "usbnet" "intel_xhci_usb_role_switch" "usbcore" "usb_common" ];

Still, it does not attempt to get a dhcp for the usb network. So I wonder what I’m missing?

how can you set parameter which are not listen in
nixos-option boot.initrd.availableKernelModules ?