Declarative audio config: How to start (and maybe use) JACK?

I switched from Ubuntu to NixOS around September. Yesterday I tried to set up audio programming in NixOS. I still can’t use JACK – and therefore not SuperCollider, or SuperCollider via Haskell (my goal).

I’ve only found one working NixOS audio config online (@magnetophon’s, described below). If you have another, I’d love to see it.

References and potential role models

After working on this problem for five hours I asked on Reddit for help. (I’m up to twelve hours now.) The one suggestion I received was that I could try a certain list of procedural changes, some subset of which, in some order, kind of worked for someone.

I’m hoping for a declarative solution instead. It seems from this Github issue that two users, @magnetophon and @MDeltaX, may have managed to do it.

What works for me, and what doesn’t

Sound works from the browser (I test using Youtube).

Supercollider claims to boot, and gives every visual indication of executing commands. However, it never generates audible speaker output. That’s true regardless of whether I start (and pless Play in) QJackctl.

I can open Cadence, hoping futz with connections and configurations. Cadence always tells me “jackdbus is not available,” and allows me no futzing. That’s true even after running jackd and/or jackdbus auto at the command line.

How are you supposed to start JACK?

Should it start automatically? Maybe I should pass some arguments to jackd, or different arguments to jackdbus?

Maybe relevant: jackdbus hangs ungracefully

When I run jackdbus auto it prints “no message buffer overruns” three times and then hangs; I can’t close the window hosting it, even if I run killall jackdbus (which I can run multiple times without receiving the usual “no process found” message, so it’s not actually killing it).

My configuration, and audio-related changes to it

Prior to working on audio, here’s what my configuration looked like. That’s the master branch. Here’s the branch where I’m experimenting with audio.

The first commit I made to the new “audio” branch consisted of these changes:

  • Add some apps to environment.systemPackages.
  • Enable Musnix as described in the Musnix readme.
  • Enable JACK as per the NixOS wiki section on JACK. (That WIKI page has a section marked “out of date”; I only acted on the notes preceding that warning.)

In the second commit, I tried to emulate the config of Github user @magnetophon. I

  • set more Musnix options
  • set services.tlp.enable = false
  • aped some stuff I don’t understand involving nixpkgs.config.packageOverrides and security.sudo.extraConfig
  • removed all mention of Pulseaudio

I also split the file audio.nix from the rest of configuration.nix.

Are my arguments in audio.nix reasonable?

My audio.nix file begins {config, lib, pkgs, options, modulesPath}:. Some of those arguments I added only because NixOS had complained in earlier versions of audio.nix that they were undefined. But some of those arguments – e.g. modulesPath – I don’t see defined anywhere in configuration.nix, which makes me nervous.


Hello @JeffreyBenjaminBrown!

How are things going for you? Any progress?

I’m in a similar place. Maybe we could compare notes?

It’s working great! I’m afraid I can’t remember quite everything I did to get there. However, my notes are online. Here’s the section of those notes containing links I found helpful. Especially helpful was this thread on Git.

And the declarative portion of my configuration is entirely available on Github. So are the custom packages I wrote (see the subfolder called that), but I don’t think you’ll need them. (They’re almost declarative. I’d like to make them part of nixpkgs but when I tried it wasn’t easy, and I don’t actually have evidence that anybody else needs them.)

Hi Jeffrey!

I’ve crossed paths with you here and also in github, though I don’t think we’ve interacted much directly.

I’ve got jack working generally and have made decent progress. But my emphasis now is on getting the several jack apps that fail to connect to the jack server to work. There is activity, but it’s kind of piece-meal and it’s evident that there something wrong systemically. All of these apps are failing in the same way and I think I’m going to roll my sleeves up and see if I can’t uncover what’s going on.

1 Like

I added a rudimentary description of what needs to be done to the Wiki (works for me).

Feel free to improve it: JACK - NixOS Wiki

Hosted by Flying Circus.