Patched kernel modules silently fail to build #10

Closed
opened 2023-12-16 09:47:15 +00:00 by jordan · 5 comments
Owner

Intermittently when input nixpkgs is bumped and contains updates to kernel-related packages, patches and overrides for modules (such as snd-usb-audio in this case) are not contained in the activated system.

No build errors are emitted.

Last occurrence was between f9cf5758e3..f0e0cf2772.

Intermittently when input `nixpkgs` is bumped and contains updates to kernel-related packages, [patches and overrides](https://git.vimium.com/jordan/nix-config/src/commit/f9cf5758e31cdc8bfdf9024ed030b74cbe557d6b/hosts/odyssey/audio.nix#L13-L17) for modules (such as `snd-usb-audio` in this case) are not contained in the activated system. No build errors are emitted. Last occurrence was between [f9cf5758e3..f0e0cf2772](https://git.vimium.com/jordan/nix-config/compare/f0e0cf27726dd89cf5a6c9336c02a7e41b8e1c5a...f9cf5758e31cdc8bfdf9024ed030b74cbe557d6b).
jordan added the
kind
bug
label 2023-12-16 09:47:15 +00:00
jordan added this to the Config Improvements project 2023-12-16 09:47:15 +00:00
Author
Owner

Occurred again on 4aa27cf9bb

nix build --print-out-paths .#nixosConfigurations.odyssey.config.boot.kernelPackages.kernel and realpath /run/booted-system/kernel shows the same kernel version is booted as was built.

/run/booted-system/kernel-modules/lib/modules/6.1.69/extra contains the patched module.

Broken build

Store paths

Package Path
kernel /nix/store/63js36518q1bgx4rniglkq43skg7rgxp-linux-6.1.69
kernel-modules /nix/store/k9104pjccqsagr4742312vk24ljh7wcw-kernel-modules
initrd /nix/store/j5ckfhkbarzy702kmi5bd059014qiaj8-initrd-linux-6.1.69
snd-usb-audio /nix/store/r9l8j7ja6611h091pl0sicvr2rsyir6a-snd-usb-audio-6.1.69

Module contained in kernel subtree is unpatched (SHA-256: 49e6366345aa422a74ceb88adaa91a1eeee935b83c06caff9d774007d75d194e), module contained in extra subtree is patched (SHA-256: 6df98f7188bb5e3f5987709db087028b1470c2d9bc9c4f436baeb088071c63d8).

In modules.dep from kernel-modules, only the original kernel version has an entry: kernel/sound/usb/snd-usb-audio.ko.xz.

Working build

Store paths

Package Path
kernel /nix/store/s5s7h6rars5q2jkdc4px448lywvxclvl-linux-6.1.68
kernel-modules /nix/store/405sghj6sxnjrdfi5jssaqbs3kk33wid-kernel-modules
initrd /nix/store/n0sp3cmmskg9105w54028iw3b0bv157v-initrd-linux-6.1.68
snd-usb-audio /nix/store/dkm9saizmdcac48cv713lx04dnv1wa3g-snd-usb-audio-6.1.68

Module contained in kernel subtree is unpatched (SHA-256: ee0db8570aeac66dbe1ac76f3aeff0e6692ccda69339f92170ba6d8358b7afdc), module contained in extra subtree is patched (SHA-256: 0cab2404b9f0afebcdb023648b44404ca588d7aab47ff033c62520add197be6a).

extra/snd-usb-audio.ko.xz has an entry in modules.dep from kernel-modules.

Occurred again on 4aa27cf9bbb434b126d733b4e431be99adad2a08 `nix build --print-out-paths .#nixosConfigurations.odyssey.config.boot.kernelPackages.kernel` and `realpath /run/booted-system/kernel` shows the same kernel version is booted as was built. `/run/booted-system/kernel-modules/lib/modules/6.1.69/extra` contains the patched module. ## Broken build ### Store paths Package | Path --|-- kernel | `/nix/store/63js36518q1bgx4rniglkq43skg7rgxp-linux-6.1.69` kernel-modules | `/nix/store/k9104pjccqsagr4742312vk24ljh7wcw-kernel-modules` initrd | `/nix/store/j5ckfhkbarzy702kmi5bd059014qiaj8-initrd-linux-6.1.69` snd-usb-audio | `/nix/store/r9l8j7ja6611h091pl0sicvr2rsyir6a-snd-usb-audio-6.1.69` Module contained in kernel subtree is unpatched (SHA-256: 49e6366345aa422a74ceb88adaa91a1eeee935b83c06caff9d774007d75d194e), module contained in extra subtree is patched (SHA-256: 6df98f7188bb5e3f5987709db087028b1470c2d9bc9c4f436baeb088071c63d8). In `modules.dep` from `kernel-modules`, only the original kernel version has an entry: `kernel/sound/usb/snd-usb-audio.ko.xz`. ## Working build ### Store paths Package | Path --|-- kernel | `/nix/store/s5s7h6rars5q2jkdc4px448lywvxclvl-linux-6.1.68` kernel-modules | `/nix/store/405sghj6sxnjrdfi5jssaqbs3kk33wid-kernel-modules` initrd | `/nix/store/n0sp3cmmskg9105w54028iw3b0bv157v-initrd-linux-6.1.68` snd-usb-audio | `/nix/store/dkm9saizmdcac48cv713lx04dnv1wa3g-snd-usb-audio-6.1.68` Module contained in kernel subtree is unpatched (SHA-256: ee0db8570aeac66dbe1ac76f3aeff0e6692ccda69339f92170ba6d8358b7afdc), module contained in extra subtree is patched (SHA-256: 0cab2404b9f0afebcdb023648b44404ca588d7aab47ff033c62520add197be6a). `extra/snd-usb-audio.ko.xz` has an entry in `modules.dep` from `kernel-modules`.
Author
Owner

On kernel upgrade, modules.dep (generated by depmod either here or here) seems to be called using only the module subtree relevant to the new kernel, rather than the entire module tree (including extra).

On kernel upgrade, [`modules.dep`](https://www.man7.org/linux/man-pages/man5/modules.dep.5.html) (generated by [depmod](https://www.man7.org/linux/man-pages/man8/depmod.8.html) either [here](https://github.com/NixOS/nixpkgs/blob/d2e4e09de4b8a27228295951c3847cfc8f06fd15/pkgs/os-specific/linux/kmod/aggregator.nix#L28-L33) or [here](https://github.com/NixOS/nixpkgs/blob/66438d3bea89fbec119bde08bb2e8bc4750c11f4/pkgs/build-support/kernel/modules-closure.sh#L96)) seems to be called using only the module subtree relevant to the new kernel, rather than the entire module tree (including `extra`).
Author
Owner
Related comment in nixpkgs issue: https://github.com/NixOS/nixpkgs/issues/56040#issuecomment-482878657
Author
Owner

After adding boot.kernelModules = [ "snd-usb-audio" ]; in f44a098f80 it seems like the derivation now contains a correct modules.dep file.

Store paths

Package Path
kernel-modules /nix/store/nvf2lyvczsnj08gzzx556q5q5fb3ypgp-kernel-modules
After adding `boot.kernelModules = [ "snd-usb-audio" ];` in f44a098f8085e619d2a38dfa200201738cf1fec5 it seems like the derivation now contains a correct `modules.dep` file. ### Store paths Package | Path ---|--- kernel-modules | `/nix/store/nvf2lyvczsnj08gzzx556q5q5fb3ypgp-kernel-modules`
Author
Owner

Issue re-occurring on latest nixpkgs. Related discussion: https://discourse.nixos.org/t/best-way-to-handle-boot-extramodulepackages-kernel-module-conflict

Added workaround for PreSonus 1824c to reload snd_usb_audio from the correct location if the device doesn't appear to have been initialised.

Issue re-occurring on latest `nixpkgs`. Related discussion: https://discourse.nixos.org/t/best-way-to-handle-boot-extramodulepackages-kernel-module-conflict Added workaround for PreSonus 1824c to reload snd_usb_audio from the correct location if the device doesn't appear to have been initialised.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jordan/nix-config#10
No description provided.