Skip to content

pulseaudioFull: pacmd cannot connect to daemon #177915

@Yarny0

Description

@Yarny0

Describe the bug

I'm using a shell script with pacmd to dynamically rename pulseaudio devices. Since NixOS 22.05, pacmd can no longer connect to the pulseaudio daemon if pkgs.pulseaudioFull is used.

Steps To Reproduce

Install NixOS (22.05 or unstable) with the option

hardware.pulseaudio.package = pkgs.pulseaudioFull;

Then login as a non-root user and execute pacmd info. It will complain

user1@nixosb:~> pacmd info
No PulseAudio daemon running, or not running as session daemon.

Other pulseaudio clients work fine, e.g.

user1@nixosb:~> pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 35
[...]

Expected behavior

user1@nixosb:~> pacmd info
Memory blocks currently allocated: 1, size: 63,9 KiB.
Memory blocks allocated during the whole lifetime: 10867, size: 96,4 MiB.
[....]

Additional context

Suspicius commit

I strongly suspect the commit 7a2605e introduced by the pull request #168012 to be the root cause. This commit adds wrapGAppsHook to the nativeBuildInputs (for bluetoothSupport which is enabled for pulseaudioFull). This setup hook replaces the pulseaudio binary by a small wrapper that calls the original wrapped binary under a new name .pulseaudio-wrapped.

However, pulseaudio notices and disapproves this replacement, as it logs during its startup

user1@nixosb:~> systemctl --user status pulseaudio.service
[....]
Jun 16 19:06:48 nixosb systemd[1958]: Starting Sound Service...
Jun 16 19:06:48 nixosb pulseaudio[2219]: W: [.pulseaudio-wra] main.c: /proc/self/exe does not point to /nix/store/bqfyzxwpxa2ydmyvh3j32xrm4chxbj22-pulseaudio-15.0/bin/pulseaudio, cannot self execute. Are you playing games?
Jun 16 19:07:41 nixosb pulseaudio[2219]: stat('/etc/pulse/default.pa.d'): No such file or directory
Jun 16 19:07:41 nixosb systemd[1958]: Started Sound Service.

Apparently, pulseaudio "remembers" its executable's path during build time and checks it at runtime.

I removed wrapGAppsHook from pulseaudio's nativeBuildInputs and nixos-rebuild the system. After a reboot, the warning disappeared from pulseaudio's log, and pacmd works fine.

Ideas for fixing

At this point, I'm not sure how to proceed. Reverting the commit would like fix the issue, but it would break whatever the wrapper tries to accomplish (I'm not sure, as I don't have bluetooth hardware, and the wrapGAppsHook isn't my area of expertise).

Several ideas come into my mind:

  • One could patch pulseaudio so it is more liberal about renamed executables. However, it is not clear a priori if this would fix pacmd or just make the warning go away -- there was probably a reason why pulseaudio doesn't like being renamed. Also, we would have to decide which executable pulseaudio should call for self execution.
  • One could move the wrapper into a wrapper package: pulseaudio builds without wrapping, then a wrapper package (e.g. buildEnv with a postBuild) could symlink all directories from the original pulseaudio package with the exception of /bin. postBuild would add wrappers in /bin which just wrap the binaries in the original package without renaming them. The wrapper package would then be the final pulseaudio package. This would only work if the wrapGAppsHook can be convinced to wrap binaries without renaming them.
  • We don't wrap the pulseaudio binaries at all, but we add all those environment variables directly into the systemd service definition which calls pulseaudio.

Notify maintainers

Metadata

root@nixosb:/etc/nixos> nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.46, NixOS, 22.11 (Raccoon), 22.11pre385289.6616de389ed`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.9.1`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions