MPD home manager songs are permanently paused

Hello,
I am using nixos with flakes and home-manager

I’m trying to set up RMPC, so I installed mpd as well

I now have my library showing up correctly in RMPC, but whenever I press enter to select a song it says [paused] at the top of the screen, and no music of course

There’s also the following error message when I try to increase or decrease the volume:
MpdError: 'Cannot execute command: 'volume'. Detail: 'No mixer'. Reason: 'system error'. Cmd idx: '0'''
(I don’t really care about being able to set the volume from there, but it might hint at the source of the other issue)

To make sure this was a MPD issue, I installed ncmpcpp as well, and there as well the song doesn’t play, and is stuck as paused

Here is the relevant part of my home.nix:

{
  config,
  pkgs,
  pkgs-unstable,
  username,
  fullname,
  hostname,
  ...
}:

{
  # <unrelated config here>

  services.mpd = {
    enable = true;
    musicDirectory = "/home/${username}/Music";

    extraConfig = ''
      audio_output {
        type "alsa"
        name "My ALSA"
        device			"hw:0,0"	# optional 
        format			"44100:16:2"	# optional
        mixer_type		"hardware"
        mixer_device	"default"
        mixer_control	"PCM"
      }
    '';
  };

  programs.rmpc = {
    enable = true;
    config = ''
      (
        address: "127.0.0.1:6600",
        password: None,
        theme: None,
        cache_dir: None,
        on_song_change: None,
        volume_step: 5,
        max_fps: 30,
        scrolloff: 0,
        wrap_navigation: false,
        enable_mouse: true,
        enable_config_hot_reload: true,
        browser_song_sort: [Disc, Track, Artist, Title],
      )
    '';
  };

  programs.ncmpcpp = {
    enable = true;
  };
}

I would appreciate some help as I really wanted to try it out !
In the meantime, I’ll use termusic

Edit:

Solution

The device was set to something that doesn’t exist on my machine, removing these optional lines fixed it:

{
  config,
  pkgs,
  pkgs-unstable,
  username,
  fullname,
  hostname,
  ...
}:

{
  # <unrelated config here>

  services.mpd = {
    enable = true;
    musicDirectory = "/home/${username}/Music";

    extraConfig = ''
      audio_output {
        type "alsa"
        name "My ALSA"
        mixer_type		"hardware"
        mixer_device	"default"
        mixer_control	"PCM"
      }
    '';
  };

  programs.rmpc = {
    enable = true;
    config = ''
      (
        address: "127.0.0.1:6600",
        password: None,
        theme: None,
        cache_dir: None,
        on_song_change: None,
        volume_step: 5,
        max_fps: 30,
        scrolloff: 0,
        wrap_navigation: false,
        enable_mouse: true,
        enable_config_hot_reload: true,
        browser_song_sort: [Disc, Track, Artist, Title],
      )
    '';
  };
}

The mixer still doesn’t work, but I’ll figure this out another day

Have you checked the logs of the mpd service? In my experience “always paused” is a symptom of mpd being unable to open the output device.

I’d love to, how can I ?

I tried the following:

> sudo journalctl mpd.service
[sudo] password for qube: 
Failed to add match 'mpd.service': Invalid argument
> journalctl mpd.service
Failed to add match 'mpd.service': Invalid argument

It’s a user service, so you need to check the user systemd instance: journalctl --user -u mpd.service.

Okay here it is:
I removed the parts about adding songs:

jun 21 10:53:18 voidbeast systemd[2101]: Starting Music Player Daemon...
jun 21 10:53:18 voidbeast mpd[21541]: exception: Failed to open "/home/qube/.local/share/mpd/tag_cache": No such file or directory
jun 21 10:53:18 voidbeast mpd[21541]: exception: Failed to open "/home/qube/.local/share/mpd/state": No such file or directory
jun 21 10:53:18 voidbeast systemd[2101]: Started Music Player Daemon.
...
jun 21 10:53:18 voidbeast mpd[21541]: Warning: Xing stream size off by more than 1%, fuzzy seeking may be even more fuzzy than by design!
jun 21 10:53:33 voidbeast mpd[21541]: mixer: Failed to read mixer for "My ALSA": no such mixer control: PCM
jun 21 10:57:24 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:57:24 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:57:24 voidbeast mpd[21541]: player: problems opening audio device while playing "Infected Mushroom - Spitfire.mp3"
jun 21 10:57:30 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:57:30 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:34 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:34 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:35 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:35 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:35 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:35 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:35 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:58:35 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:59:01 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 10:59:01 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 11:08:54 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 11:08:54 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 11:08:55 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 11:08:55 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
jun 21 11:08:55 voidbeast mpd[21541]: exception: Failed to open "My ALSA" (alsa); Failed to open ALSA device "hw:0,0": Device or resource busy
...

So it does seem related to the output device

I use plasma is there a way to let it handle the output device ?

That’s what pulseaudio and (more recently) pipewire are for. You want mpd playing through those, not directly through alsa, most likely.

I see, thank you

I think removing the device part solved it:

  services.mpd = {
    enable = true;
    musicDirectory = "/home/${username}/Music";

    extraConfig = ''
      audio_output {
        type "alsa"
        name "My ALSA"
        mixer_type		"hardware"
        mixer_device	"default"
        mixer_control	"PCM"
      }
    '';
  };

From the nixos wiki it seemed like alsa would be a lot simpler since it talked a lot about issues between user and system communication
I guess this wouldn’t apply in my case since it’s all in home-manager ?

Correct. When mpd is run as a user service, which it is when set up through the home-manager module, it inherits all the right environment information to connect to the pulseaudio or pipewire daemon. When set up through the nixos module it runs as a system service and it can be quite a pain to get it to connect to the audio server in that case.

Nice thanks !

Do you think you could add a home-manager section to the nixos wiki ?

If not I can try to do it

I gave it a shot. I don’t usually edit the wiki, but there’s a first time for everything, I guess.

2 Likes