NixOS and Linux (Pro) Audio

This is a thread about using audio software on NixOS.

To use Jack without xruns, add the following to configuration.nix:

  security.pam.loginLimits = [
    { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
    { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
    { domain = "@audio"; item = "nofile"; type = "soft"; value = "99999"; }
    { domain = "@audio"; item = "nofile"; type = "hard"; value = "99999"; }
  ];

And add yourself to the audio group.

3 Likes

Iā€™ve created a nix file for Carla: https://gist.github.com/suhr/912c714c9ac73ccfc0d52303e1caeb7c

At a standalone app it works great. But when I try to use it as a VST plugin in Helio, it cannot find PyQt5.

How can I fix that problem?

2 Likes

I recommend creating a Python 3 environment, and using that in buildInputs.

pythonEnv = python3.withPackages(ps: with ps; [ pyliblo pyqt5 ])

If there are shebangs in the scripts, then they should be rewritten to the path of the Python in this env.

Thanks! Though instead of PyQt5 problem I have now this: Could not initialize GLX.

Standalone version works as usually.

Maybe you cannot find your opengl libraries? LD_DEBUG=libs <your command> might help. Otherwise strace -f <command> might show if it tries to access some devices or so.

would be great if you could make a PR to have carla upstream.

Nixpkgs PR process is rather slow, so Iā€™m going to make an overlay first.

By the way, this is a nix file for Helio (git): https://gist.github.com/suhr/1eb9b2d4d9539c130ff8a28e6beb3ba2

thanks for the info ! nd packages :loud_sound::loud_sound::loud_sound:

btw have you heard of musnix? RT audio in NixOS config ect.

2 Likes

i guess the overlay
could be added to NUR ?
link: Introducing NUR - the Nix User Repostory || Share all your nix expressions! - #9 by Mic92

could be added to NUR ?

If I figure out how to use it, then why not.

I created a nur repository with packages: GitHub - suhr/nur-packages

Also, thereā€™s an issue for Carla: Carla in NixOS Ā· Issue #813 Ā· falkTX/Carla Ā· GitHub. By the way, removing /run/current-system/sw/lib from LD_LIBRARY_PATH revealed an another issue: Carla cannot find libjack2.so.0.

1 Like

Iā€™ve done audio production with Debian for at least a couple of decades, but Iā€™m relatively new to NixOS and Iā€™m having a very difficult time. Iā€™ve had great success on Debian using classic jack, but Iā€™ve never used jackdbus; Iā€™ve always just killed pulseaudio when necessary, if I even ran it at all.

Iā€™ve had very limited success following JACK - NixOS Wiki as best I can. I have been able to use a few jack clients, notably ardour5, but most apps fail to connect for me.

I also have trouble with ardour hanging up very regularly, usually (though not always) accompanied by:

kernel: xhci_hcd 0000:00:14.0: WARN Event TRB for slot 1 ep 1 with no TDs queued?

in my journal logs. I have no reason to expect this is related to my general jack woes, but I suppose it could be.

How are people generally going about this?

My inclination at this point is to go back to zero and try using jack1 without pulseaudio and see how things go. At least it would be simpler and more familiar.

Would anyone be willing to share a bit of your working config?

1 Like

This is quite strange. Do you still have this problem?
I just installed NixOS on an old macbook air with an audio config i copied over from an old laptop and it seems to work without any troubles. Iā€˜ve only used Ardour + some Plugins tho. But I also got it working alongside pulseaudio with jack-sink. I can upload my config if youā€˜re interested

1 Like

Well, I did manage to get things working. Shortly after having posted the above. But jackd broken again soon after. Iā€™m fine as long as I stay on the generation from March or so. But itā€™s broken for all builds since then.

Is it still working for you?

Hey folks. I put together gist with pulse + jack and pipewire based setups which work for me on recent nixos unstable.

Note that some parts of that config might not be even needed since nixos/jack,pulseaudio: fix pulse connection to jackd service by sorki Ā· Pull Request #93431 Ā· NixOS/nixpkgs Ā· GitHub but I kept them in anyway.

Let me know if you have some difficulties setting this up still. I also think it would be awesome, in case that this works, if someone would update wiki page. Preferably someone other than me who knows more about pro audio and can english better than I. Iā€™m not an expert on this sort of stuff but Iā€™m happy to help to the extend Iā€™m able to.

2 Likes

Referencing your sound-traditional.nix:

extraOptions = [ ā€œ-dalsaā€ ā€œā€“deviceā€ ā€œhw:1,0ā€ ];

Is it necessary to hardcode the device in the configuration?

And regarding the pipewire config, Iā€™m not sure what that was supposed to enable, but I couldnā€™t work with jack at all with that config. The jack daemon failed to start.

Iā€™m struggling to get jack working at all anymore ā€“ with or without pulse. My music machine is running a version of nix from Feb 2020.

Any updates on this? Am I the only one attempting to do audio production on NixOS?

Iā€™ve been using Reaper and some VST plugins on my NixOS-based Laptop to use it as a guitar amp. Running this on Pipewire and it worked pretty ok.

But itā€™s very much a side-project that I work on whenever I have some time. I donā€™t really understand your issue though (well, except that things donā€™t seem to work) and I doubt that I can say anything about a 2020 version of Nix since this is before I even started using it.

The relevant Pipewire config is in here: https://github.com/polygon/dotfiles/blob/964ade7bb58dfe03add4735ee9957f3e18554466/systems/nixbrett/nixbrett.nix

2 Likes

FWIW, Iā€™m using ardour, qjackctl and a fair number of plugins on nixos (amd64 - ryzen) and basically only have

  musnix = {
    enable = true;
  };
  ...
  sound.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = false;
    pulse.enable = true;
    jack.enable = true;
  };

and itā€™s working pretty ok. I remember I tried some additional musnix optimisation settings (incl. rt kernel) about a year ago but failed due to build/boot etc. errors, so I kept it simple. But it does the job (I mainly use ardour with a Focusrite Scarlet 18i8 for recording and mixing) well enough.

Iā€™m updating pretty frequently though, and find improvements generally outweigh the few regressions encountered; so Iā€™d advise to get current first on that machine if thereā€™s no compelling reason to keep it ā€œ2020ā€.

1 Like

Interesting. I have services.pipewire.enable = true but I havenā€™t set sound.enable = false ā€¦ do you know what difference it makes, if any?