NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.45k stars 13.65k forks source link

pipewire-media-service Systemd service not working properly #145556

Closed cideM closed 2 years ago

cideM commented 2 years ago

Describe the bug

I'm using a pretty stock configuration for PipeWire, and my NixOS is built from a Flake where Nixpkgs is set to 9cad36c40accad65c59368c6b9d27b3d99268e41. This includes the most recent PipeWire updates from https://github.com/NixOS/nixpkgs/commit/b65f74fd98b06a84a67b66138d31be8419612c09#diff-6c167307e84d42c088d640f1859ad87e6c8cb15c1ce2353361eac78b5351027e

Here's the configuration:

{
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    media-session = {
      enable = true;
      package = pkgs.pipewire-media-session;
    };
    pulse.enable = true;
  };
  hardware.pulseaudio.enable = false;
}

But it seems that the pipewire-media-service Systemd service isn't running. I need to run the binary manually to have sound.

$ systemctl status --user pipewire-media-session
Unit pipewire-media-session.service could not be found.

~/dotfiles on master •
$ ls -lah ~/.config/systemd/user/pipewire-media-session.service
lrwxrwxrwx 1 tifa users 120 Mar 17  2021 /home/tifa/.config/systemd/user/pipewire-media-session.service -> /nix/store/rk1mvrg2xcbnzhxm1wfnwm46i092kas3-pipewire-0.3.23-mediaSession/lib/systemd/user/pipewire-media-session.service

~/dotfiles on master •
$ ls -lah (readlink ~/.config/systemd/user/pipewire-media-session.service)
ls: cannot access '/nix/store/rk1mvrg2xcbnzhxm1wfnwm46i092kas3-pipewire-0.3.23-mediaSession/lib/systemd/user/pipewire-media-session.service': No such file or directory

Notice how the file path for the media session isn't valid.

nix store verify /nix/store/rk1mvrg2xcbnzhxm1wfnwm46i092kas3-pipewire-0.3.23-mediaSession
...
error: path '/nix/store/rk1mvrg2xcbnzhxm1wfnwm46i092kas3-pipewire-0.3.23-mediaSession' is not valid

I have no idea what to do at this point.

Notify maintainers

@jansol

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.1, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.5pre20211007_844dd90`
 - channels(tifa): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
jansol commented 2 years ago

Delete the symlink from ~/.config/systemd/user so it gets recreated correctly. Seems flakes (and I think I've heard about home-manager doing this too) have a tendency of not always updating service symlinks in $HOME correctly.

EDIT: as you can see the symlink there refers to a much, much older pipewire version than what your flake should contain.

cideM commented 2 years ago

I deleted the symlinks but they weren't being recreated. I commented out the whole PipeWire part of my configuration but to no avail. In the end I manually ran systemctl --user enable pipewire-media-session and now it's running and I have sound. Not quite sure if this is some kind of intereference between the older Nixpkgs commit I was using first and what the newer Nixpkgs commit now wants to do, with regards to putting systemd services in the user folder.

I'll close this issue since I also had a crash during an update after which I nuked /nix/var/nix/profiles/per-user/tifa/ so maybe this severed the connection between the symlinks and the Nix store and as such the files were just left in place.

Why I'm unable to convince Nix to recreate the symlinks even through repeated uncommenting and commenting I don't know.