NixOS Wiki: Audio

From NixOS Wiki
Jump to: navigation, search

This is a basic setup cookbook for a new NixOS user on contemporary hardware.

This cookbook presumes the following:

  • Your aim is good, reliable audio for playing songs, Internet videos, movie watching, and so on.

That is, you're not looking to setup pro audio for multi track music production, podcast creation, et cetera.

  • Your computer is circa 2017 or newer.
  • You are using a classic NixOS channels configuration and not the experimental flakes configuration.
  • You are running KDE Plasma 6, which provides graphical volume and bluetooth controls. If not, you will need to install additional packages to raise/lower the volume and pair your bluetooth audio device:
    pavucontrol # PulseAudio Volume Control
    pamixer # Command-line mixer for PulseAudio
    bluez # Bluetooth support
    bluez-tools # Bluetooth tools

1) Add the following to your configuration.nix

  #
  # Audio
  #
  hardware.pulseaudio.enable = false; # Use Pipewire, the modern sound subsystem

  security.rtkit.enable = true; # Enable RealtimeKit for audio purposes

  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # Uncomment the following line if you want to use JACK applications
    # jack.enable = true;
  };

  #
  # Bluetooth
  #
  hardware.bluetooth = {
    enable = true;
    powerOnBoot = true;
  };

2) Run these commands:

nix-channel --update ; nixos-rebuild switch

Note: These commands will freshen all software and configuration settings.

Postscript

I hope this helps someone. The more time I spend with NixOS, the more I realize that the developers worked very hard to provide easy and sane defaults. I went down a few rabbit holes before landing on this config. There's a lot of convoluted audio setup examples on the Internet. I tried several of them. This simple configuration works great for me on a diverse collection of PC's with varying hardware inside. -- Joe Kotran -- Nov 9, 2024