State of jackd in NixOS

Is anyone here producing audio/music on NixOS? I’ve been trying for some time and I am met with a great deal of frustration so far.

If I try the jack2/dbus/pulseaudio approach, I am able to use ardour and a few other jack clients, but the great majority fail to connect. I am contemplating trying jack1 in userspace, since this is what has worked extremely well for me for many years.

Also – and this could be totally unrelated – ardour constantly freezes up on me and it seems to coincide with some xhci warnings in the system logs:

xhci_hcd 0000:00:14.0: WARN Event TRB for slot ep [y] with no TDs queued?

All my googling would lead us to believe that this is a benign warning. But the coincidence is strong and I’m not convinced.

Is anyone willing to bang their heads on this wall alongside me?

3 Likes

Whatever little I’ve read from this link Fedora Muscian's Guide | Hacker News people seem to think that Linux shouldn’t be used for music production… Not trying to dissuade you (I’m a nixos full time user) but figured this would put things in perspective for other readers here (assuming you’ve already done your own research)

2 Likes

I have a friend that does a fair amount of music production on an Ubuntu desktop. I seem to recall him saying how much research was required to get everything working (including jack), and how he’s terrified to ever update because he’s not exactly sure on the steps he took to get things working. At that point I suggested he needed NixOS because with NixOS you never have to wonder what you did to get something to work - you just look at configuration.nix :wink:

He’s still using that Ubuntu LTS :man_shrugging: I would guess that our community isn’t large enough to contain more than a couple musicians who use their computers for music production unfortunately. On the plus side if you had explicit instructions for another distribution (maybe Ubuntu?) someone might be willing to help you adapt the configuration to NixOS. Maybe NixOS would become popular with musicians as all I’ve ever heard is that it’s a real nightmare to configure.

Good luck!

2 Likes

There are a lot of people using Linux and open source tools to make music. That being said, it is relatively complicated to get it configured initially. I haven’t tried on Nixos yet but I did get it all working in Arch a while back.

There are also spins of various distributions that ship with jack/jack2 preconfigured.

1 Like

Maybe it is solved in Muznix , which is nix for musicians: GitHub - musnix/musnix: Real-time audio in NixOS

2 Likes

Thanks for the replies. I think I may not have been clear regarding my starting point.

As far as audio production with linux (Debian, for the most part) and FOSS per se, I’ve been at it for at least 20 years and it has been very satisfying. Matters are certainly much better now than when I started. It’s more specifically NixOS and jackdbus that are new to me and with which I’m struggling. I could retreat back to Debian and continue as I have.

I’ve used jack1 successfully for many of those years, though jack1 doesn’t cooperate well with pulseaudio. I’ve not found it terribly inconvenient to simply kill pulseaudio when I wanted to do more serious, jack-related things. Sometimes, I’d just remove it altogether if the machine was dedicated to audio production.

I’ve happily used Nix as a secondary PM for a few years now, but I only recently switched from Debian to NixOS. There are still some wrinkles I need to iron out, but I’ve been really excited with it so far and I don’t regret the swap. It seems the standard NixOS approach is to go with jack2/jackdbus and interop it with pulseaudio, which sounds like a great idea, in principle. Another advantage is that it’s a proper service and its config can be declared in configuration.nix, which I see as a big win.

However many jack clients are unable to connect to it for some reason. That’s why I’m considering abandoning that approach and trying to go back to jack1, which is familiar to me.

@stphrolland Muznix is very interesting, but it’s specifically about kernel configuration. I think it’ll come in handy when I’ve solved these more fundamental problems. But I saw your response before you edited it and I think your suggestion to try to contact those people is a good one. Clearly they’ll have worked through some of this.

@aanderse I agree that the reproducibility that NixOS brings is very attractive – that’s what I’m here for. Unfortunately, I may lose that if I switch to a non-service. I really need to try home manager, so things aren’t so imperative.

@sjfloat Just in case that could be related, in my journalctl -b I have tons of messages “jack server is not running or cannot be parsed”. Almost one every seconds. Only thing I’m sure, it’s not because of ardour, and I have even uninstalled it to be sure, and the error still happens.

What are such jackd clients that are failing you ?

1 Like

@stphrolland ingen and guitarix are a couple that I remember off-hand, but there were quite a few; none of which I’ve ever hand any trouble with before (well, not that trouble, anyway).

And yeah, I get those in my journal as well.

Well, I believe I have resolved the freeze-ups. The problem seemed to be due to some weirdness in XHCI and my audio interface, a Lexicon Lambda, is USB 2.0 based.

So I simply moved it from the USB 3.0 port it was in to a 2.0 port and the issue seems to have completely cleared up! I played back a loop for several minutes and it was rock solid (and no XRUNs either, incidently).

I think my next order of business will be to divorce my jack and pulseaudio setups and see I can figure out why so many jack clients can’t connect.

Progress!

6 Likes

Well, a quick issue search reveals that there are a significant number of jack applications that are unable to connect to the jack server under NixOS. So this isn’t really a matter of bugs in the individual upstream packages. This is something more widespread.

I’ve still reached no resolution to these problems. I’m going to dedicate a machine to this and start again from scratch so as not to disrupt the boxes I need to be stable.

1 Like

For what it’s worth, I’m on NixOS+GNOME+Pipewire on the stable channel, and I’ve been happily using Ardour, Carla and PD via their JACK implementations. You can even still use qjackctl to route signals around, all while Firefox or Spotify or whatever continues to play via their pulseaudio implementation in the background.

I had one issue with PD, but it turned out to be a bug in PD where their JACK backend assumed a shorter possible device name length than what was actually possible. My Intel machine + pipewire manages an extremely long and specific device name that triggered this :woman_facepalming:

I also used to have issues with Ardour where I couldn’t render tracks as they were missing some part of the JACK API that allowed offline rendering, but that was fixed a few months ago I believe.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.14.2, NixOS, 21.05.3065.b3083bc6933 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.15`
 - channels(root): `"nixos-21.05.3065.b3083bc6933"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
2 Likes

Checking in again. I’ve been totally unable to get jack working since February of 2020. If anything, it’s much worse than before. I’ve tried disabling pulse altogether but it hasn’t helped. As a baseline, I’m able to work with Ardour flawlessly, directly with alsa. When I disable pulse and back Ardour with jack, I’m unable to playback through the device for which it is configured. It simply disregards my configuration and plays through the onboard hardware. Recording with the outboard gear works as long as I disable pulse.

As of February of 2020, when I initiated this thread, I was using many jack based apps with a few critical apps failing. Now, even the simplest tests with only Ardour fail.

Is anyone doing any pro-audio with nix and, if so, would you be willing to compare notes with me. I’d greatly appreciate any help.

2 Likes

I’m afraid I don’t have any JACK-package-specific advice, but have you given pipewire (which provides a JACK implementation) a go? As mentioned in my previous comment, I’ve been working with Ardour, Carla and PD via their JACK implementations without issues, on a GNOME DE fwiw.

My audio config looks something like this:

  # Load the sequencer and midi kernel modules.
  boot.kernelModules = ["snd-seq" "snd-rawmidi"];
  users.extraUsers.mindtree.extraGroups = [ "audio" "realtime" ];

  services.pipewire = {
    enable = true;
    alsa = {
      enable = true;
      support32Bit = true;
    };
    jack.enable = true;
    pulse.enable = true;
  };

  # Must disable pulseaudio to allow for the pipewire pulseaudio emulation.
  hardware.pulseaudio.enable = false;

Then these are all the audio packages I’m using in my home-manager:

    home.packages = with pkgs; [
      ardour
      calf
      carla
      geonkick
      helm
      lsp-plugins
      mixxx # DJ mixer
      noise-repellent
      paulstretch
      #puredata
      qjackctl
      sfizz # sfz sampler
      supercollider
      surge
      swh_lv2
      vmpk # virtual midi keyboard
      x42-avldrums
      x42-gmsynth
      x42-plugins
      zam-plugins # Some random plugins I'm about to try
      zynaddsubfx # Plugin

      # Remove this in favour of `puredata` above once the
      # `fix-jack-client-name-len` patch is merged into the pure data, is
      # published in a new version and the new version is available in nixpkgs.
      (callPackage /home/mindtree/programming/nix/puredata/puredata.nix {})
    ];

Feel free to disregard if you’re set on the jack package itself. However, as a GNOME user dealing with JACK has always been a nightmare due to the pervasiveness of pulseaudio throughout the GNOME DE - I’ve never managed to get the two working nicely side by side. Pipewire has been a proper miracle in that regard.

2 Likes

Thanks for the response,

I’ll continue to explore pipewire, but I’m afraid it might not be quite ready yet per this discussion from the Ardour forum in Octobter:

Do you know whether they’ve moved beyond the issue with overdub alignment?

1 Like

Also, might I ask what nix channel you’re using? I’m on unstable.

I’m still on stable:

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.4, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.16`
 - channels(root): `"nixos-21.11.333896.a640d8394f3"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

I’ve mostly been using Ardour for sound design and as a host for instruments for performing generative music via MIDI, so I haven’t been paying close attention to latency. Robin’s link to the pipewire wiki in that issue seems to have some more info https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Performance#latency

1 Like

21.11 has only been ‘stable’ for less a month. But hey… in other news, not that i should tell you what to do, but you should make a you tube on your sound production nixos adventure and tell us the good, the bad, and the ugly.

Well, rubber ducking with people like you all has been helpful. I made a break-through yesterday. I realized one thing that was throwing me off was that my years of experience of using jack involved my running it as a userland app. I was starting and stopping and tweaking it with either qjackctl or by invoking it directly. But the NixOS way treats it as a service defined declaratively in the overall definition of my entire system. So I realized the analogous thing would be to do what I normally did at the command line as hardcoded parameters in my configuration.nix. So I now have vanilla jack and alsa nominally working again and I am on my way. There are still a lot of details to work out, of course, and I’m still not where I was in February 2020. But this is a milestone for me.

My high-level goals are:

  1. Establish a dedicated laptop music workstation. I don’t care if I have pulse or pipewire working there at all. In fact, I’d rather not at this point. I’m aiming for familiarity, simplicity, and minimal moving parts.

  2. Get my general-purpose desktop box back on a current nix channel (vs the the very old pinned one) and get the now normal hybrid behavior where both pulse and jack live harmoniously together. I expect pipewire will be part of that solution and my audio performance demands will be less stringent.

I have git branches and grub submenus for each of the above.

1 Like

where are these git repo’s. Maybe a good use for system configuration with flakes, it would nice to get a new laptop and ‘install’ a open source audio workstation, with all the bells and whistles working in a state the can be fully reproducible. warts n all.

I think Nix/OS may be able to really shines at building tailored specific dedicated operating system for this kinda stuff, this as long as audio software and subsystems can stand being nixified.

It just takes a bit of effort and time, something i seem to be lacking right now (time).

1 Like