Sound on Raspberry Pi 4

Has anyone had success in getting sound to work RPi4 devices? What I’ve tried so far:

  • Adding dtparam=audio=on to boot.loader.raspberryPi.firmwareConfig and rebuilding the SD image
  • Manually adding the aforementioned boot option to the config.txt file in the boot partition
  • Enabling ALSA and Pulseaudio

Nothing has helped by get a running system where aplay -L yields more than the null card. Is there anything I’m missing here?

I’m not positive, but I think you might have to use linuxPackages_rpi4.

EDIT: It doesn’t look like the PWM audio driver was ever mainlined, so this is probably the case.

I had success having sound on the RPi4 jack output using this config.
All of it may not be necessary since I tried a lot of things.

{ pkgs, lib, flakeInputs, ... }:
  imports = [
    # ...

  boot = {
    extraModprobeConfig = ''
      options snd_bcm2835 enable_headphones=1

  hardware.raspberry-pi."4" = {
    fkms-3d.enable = true;
    audio.enable = true;
    dwc2.enable = true;

  hardware.pulseaudio = {
    enable = true;
    package = pkgs.pulseaudioFull;

I also manually added


in the config.txt file. But I am not sure that it is needed.

I’m pretty sure the important part of that is nixos-hardware using the kernel that I mentioned, but I could be wrong.

Thanks for your answers! I copied @nurelin’s config and something in there seemed to do the trick :wink: