Running pipewire on 20.09

Hi! I started looking into this because I wanted to use SuperCollider (or Overtone and Sonic-Pi to be more precise) on Nix. My previous setup on Arch was a bit of a PITA and I was hoping to simplify it greatly in my current NixOS setup.

I came across Pipewire and it sounds too good to be true. It seems like the programs I want to use will mostly work without a babashka of different interwoven audio services. That’s my first question – does it even do what I think it does? Can I simply start the pipewire service at boot and forget about managing a jackd instance?

Now, when trying to set it up, I came across this gist which was posted here in a thread about professional audio. I’d like to use the service from unstable. I set up the unstable channel and changed my configuration.nix, the relevant parts look like this:

{ config, lib, pkgs, ... }:
 
 
{
  imports =
    [ 
      <nixos-hardware/lenovo/thinkpad/t460s>
      <nixos-unstable/nixos/modules/services/desktops/pipewire/pipewire.nix>
      # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];
  disabledModules = [
    "services/desktops/pipewire.nix"
  ];
 
  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = false; # explicitly set to false for pipewire
  services.pipewire = {
    enable = true;
    alsa = {
      enable = true;
      support32Bit = true;
    };
    pulse.enable = true;
  };
 
  # ...
}

Trying to build it however fails. I’m trying to understand why. Why is cfg.package.pulse undefined? And how can I provide it? Do I need some other package from unstable?

You also need the pipewire package from unstable, because the version in stable is lacking the pulse passthru.

Probably this would already suffice:

{
  services.pipewire = {
    enable = true;
    package = nixos-unstable.pipewire;
    # ...
  };
}
1 Like

The pipewire setup I’ve posted is compatible with unstable channel. Pipe wire support is alpha/beta so the unstable is only channel that makes sense to use as it will receive improvements more quickly.

For switching channels see https://nixos.org/manual/nixos/unstable/#sec-upgrading or Nix channels - NixOS Wiki

I managed to get pipewire from unstable to work on 20.09 as follows:

{ config, pkgs, ... }:

let
  unstable = import <nixos-unstable> { };
in {
  imports = [
    <nixos-unstable/nixos/modules/services/desktops/pipewire/pipewire.nix>
    <nixos-unstable/nixos/modules/services/desktops/pipewire/pipewire-media-session.nix>
    ./hardware-configuration.nix
  ];
  disabledModules = [
    "services/desktops/pipewire.nix"
    "services/desktops/pipewire-media-session.nix"
  ];

  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    package = unstable.pipewire;
    alsa = {
      enable = true;
      support32Bit = true;
    };
    pulse.enable = true;
    # jack.enable = true;
    media-session = {
      enable = true;
      package = unstable.pipewire.mediaSession;
    };
  };
}
1 Like

That is fantastic! Thanks for sharing your config. I’m unsure if it was services.rtkit or pipewire.mediaSession, both of which were lacking from my config. Can confirm this works for me as well, along with jack.enable = true :slight_smile:

1 Like

I am noticing a higher CPU load than normal for polkitd and dbus-daemon since making this change. Not sure what that’s about…