{
  lib,
  config,
  pkgs,
  ...
}: let
  cfg = config.music.mpd;
in {
  options = {
    music.mpd.enable = lib.mkEnableOption "Music Player Daemon";
  };

  config = lib.mkIf cfg.enable {
    home.packages = with pkgs; [
      mpc-cli
      ymuse
    ];
    services.mpd = {
      enable = true;
      musicDirectory = "${config.home.homeDirectory}/Music/";
      network.startWhenNeeded = true;
      extraConfig = ''
        restore_paused "yes"
        auto_update "yes"
      '';
    };
    services.mpd-mpris.enable = true;
    services.mpdris2.enable = true;
  };
}
