vmTools: point in-VM module loading at kernelModules too

The previous commit split the module tree out of `kernel` into a new
`kernelModules` argument, but only updated the initrd modules closure.
Two other places still referenced `kernel` for modules:

* `MODULE_DIR` in stage2Init, which backs both the kernel automatic
  module loader (/proc/sys/kernel/modprobe) and any explicit modprobe
  run inside the VM;
* the `/lib` symlinks in extractFs and extractMTDfs.

Before the split these pointed at the aggregated tree whenever callers
overrode `kernel` with one, so e.g. `modprobe zfs` inside the VM found
the out-of-tree module. Verified by running modprobe of a module
present only in `kernelModules` inside runInLinuxVM: it fails with
"FATAL: Module zfs not found" before this change and succeeds after.

Assisted-by: Claude Code (claude-fable-5)
This commit is contained in:
Philip Taron
2026-06-11 09:55:27 -07:00
parent 68d32ed6cb
commit e741e98346
+3 -3
View File
@@ -235,7 +235,7 @@ let
fi
# Set up automatic kernel module loading.
export MODULE_DIR=${lib.getOutput "modules" kernel}/lib/modules/
export MODULE_DIR=${lib.getOutput "modules" kernelModules}/lib/modules/
${coreutils}/bin/cat <<EOF > /run/modprobe
#! ${bash}/bin/sh
export MODULE_DIR=$MODULE_DIR
@@ -432,7 +432,7 @@ let
name = "extract-file";
buildInputs = [ util-linux ];
buildCommand = ''
ln -s ${kernel}/lib /lib
ln -s ${kernelModules}/lib /lib
${kmod}/bin/modprobe loop
${kmod}/bin/modprobe ext4
${kmod}/bin/modprobe hfs
@@ -464,7 +464,7 @@ let
mtdutils
];
buildCommand = ''
ln -s ${kernel}/lib /lib
ln -s ${kernelModules}/lib /lib
${kmod}/bin/modprobe mtd
${kmod}/bin/modprobe mtdram total_size=131072
${kmod}/bin/modprobe mtdchar