Pipewire host not found and is inactive

I’m using mpd and I used the code on the wiki for pipe wire with its workarounds. The only issue is with pipewire
here’s my setup for mpd and pipewire respectively:


services.mpd.user = “hammoud”;

systemd.services.mpd.environment = {
# Fails if ran without XDG_RUNTIME_DIR (#609) · Issues · PipeWire / pipewire · GitLab
XDG_RUNTIME_DIR = “/run/user/${toString config.users.users.hammoud.uid}”; # User-id must match above user. MPD will look inside this directory for the PipeWire socket.
};

services.mpd = {
enable = true;
musicDirectory = “/home/hammoud/Music”;
extraConfig = ‘’
audio_output {
type “pipewire”
name “My PipeWire Output”
}
‘’;


  # Optional:
  network.listenAddress = "any"; # if you want to allow non-localhost connections
  startWhenNeeded = true; # systemd feature: only start MPD service upon connection to its socket


};

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

here’s the systemctl for mpd:

15 12:18:15 nixos systemd[1]: Starting Music Player Daemon…
15 12:18:15 nixos mpd[14321]: zeroconf: No global port, disabling zeroconf
15 12:18:15 nixos systemd[1]: Started Music Player Daemon.
15 12:18:23 nixos mpd[14321]: exception: Failed to open “My PipeWire Output” (pipewire); Failed to connect stream: Host is down
and for pipe wire:
○ pipewire.service
Loaded: masked (Reason: Unit pipewire.service is masked.)
Active: inactive (dead)

You have to either start mpd as a user service (via home-manager for example), or start pipewire in the system-wide configuration. For the latter use something like this:

{
  services.pipewire.enable = true;
  services.pipewire.alsa.enable = true;
  services.pipewire.systemWide = true;

  sound.enable = true;

  services.mpd = {
    enable = true;
    musicDirectory = "/mnt/share/Music";
    network.listenAddress = "any";
    extraConfig = ''
      audio_output {
        type "pipewire"
        name "PipeWire Sound Server"
      }
    '';
  };

  systemd.services.mpd.serviceConfig.SupplementaryGroups = [ "pipewire" ];
}
1 Like

thank you, I just copied the line of code. I don’t want to use home manager because I’m still trying to wrap my head around this and the concept of using one whole file to configure everything is nice