git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/jack,pulseaudio: fix pulse connection to jackd service

This fixes the case when Jack Audio Daemon is running as a service via `services.jack.jackd` and Pulseaudio running as a *user* service. Two issues prevented connecting `pulse` with `jackd`: * Missing `JACK_PROMISCUOUS_SERVER` environment variable for `pulse` user service, resulting in `pulse` trying to access `jackd` as if it was running as part of the users session. * `jackd` not being able to access socket created by `pulse` due to socket created using user ID and `users` group. Change allows `jackd` to access the socket created by `pulse` correctly. `pulse` now also autoloads `module-jack-sink` and `module-jack-source` if `services.jack.jackd.enable` is set. The default `pulse` package is now set to `pulseaudioFull` automatically if `services.jack.jackd.enable` is set.

commitf54612264edd7d743488e6469b5f774dbc07e7b7 authorRichard Marko <srk@48.io> dateSat 18 Jul 2020, 13:32 (6 years ago) parentf3bf0f1
2 files changed+10−1
nixos/modules/config/pulseaudio.nix+7−1 nixos/modules/services/audio/jack.nix+3
nixos/modules/config/pulseaudio.nix+7−1
@@ -36,6 +36,8 @@ let
3636 ${addModuleIf cfg.zeroconf.discovery.enable "module-zeroconf-discover"}
3737 ${addModuleIf cfg.tcp.enable (concatStringsSep " "
3838 ([ "module-native-protocol-tcp" ] ++ allAnon ++ ipAnon))}
39+ ${addModuleIf config.services.jack.jackd.enable "module-jack-sink"}
40+ ${addModuleIf config.services.jack.jackd.enable "module-jack-source"}
3941 ${cfg.extraConfig}
4042 '';
4143 };
@@ -144,7 +146,9 @@ in {
144146
145147 package = mkOption {
146148 type = types.package;
147− default = pkgs.pulseaudio;
149+ default = if config.services.jack.jackd.enable
150+ then pkgs.pulseaudioFull
151+ else pkgs.pulseaudio;
148152 defaultText = "pkgs.pulseaudio";
149153 example = literalExample "pkgs.pulseaudioFull";
150154 description = ''
@@ -284,6 +288,8 @@ in {
284288 RestartSec = "500ms";
285289 PassEnvironment = "DISPLAY";
286290 };
291+ } // optionalAttrs config.services.jack.jackd.enable {
292+ environment.JACK_PROMISCUOUS_SERVER = "jackaudio";
287293 };
288294 sockets.pulseaudio = {
289295 wantedBy = [ "sockets.target" ];
nixos/modules/services/audio/jack.nix+3
@@ -246,6 +246,9 @@ in {
246246 description = "JACK Audio Connection Kit";
247247 serviceConfig = {
248248 User = "jackaudio";
249+ SupplementaryGroups = lib.optional
250+ (config.hardware.pulseaudio.enable
251+ && !config.hardware.pulseaudio.systemWide) "users";
249252 ExecStart = "${cfg.jackd.package}/bin/jackd ${lib.escapeShellArgs cfg.jackd.extraOptions}";
250253 LimitRTPRIO = 99;
251254 LimitMEMLOCK = "infinity";