How can I disable a kernel module?

I have a Lenovo m92p and I want to disable the Analog Out, but keep the HDMI Out.

I try to disable a kernel module

  #Disable Internal Soundcard Analog Out
  boot.blacklistedKernelModules = [ "snd_hda_codec_generic" "snd_hda_codec_realtek" ]; 

, but after a reboot, I still see that kernel module listed

[b0ef@m92p:~]$ lsmod|grep -i snd
snd_seq_dummy          16384  0
snd_hrtimer            16384  1
snd_seq                90112  7 snd_seq_dummy
snd_seq_device         16384  1 snd_seq
snd_hda_codec_hdmi     81920  1
snd_hda_codec_generic    98304  1
ledtrig_audio          16384  1 snd_hda_codec_generic
led_class              20480  1 snd_hda_codec_generic
snd_hda_intel          57344  1
snd_intel_dspcfg       36864  1 snd_hda_intel
snd_intel_sdw_acpi     20480  1 snd_intel_dspcfg
snd_hda_codec         176128  3 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel
snd_hda_core          118784  4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
snd_hwdep              16384  1 snd_hda_codec
snd_pcm               155648  4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
snd_timer              49152  3 snd_seq,snd_hrtimer,snd_pcm
snd                   118784  13 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_timer,snd_pcm
soundcore              16384  1 snd
firmware_class         49152  5 snd_hda_intel,xhci_pci_renesas,drm_display_helper,i915,drm

How come?:wink:

Did you rebuild and switch?

Yes, I rebuilt and switched.

Are the modules perhaps baked into the initrd and loaded there? The option only applies to module loads after boot AFAICT as it’s merely a file in /etc/. Check the auto-generated hardware-configuration.nix.

  boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ ];
  boot.extraModulePackages = [ ];

We have no command to check the modules if they are what you think they may be?