{
  lib,
  config,
  pkgs,
  ...
}: let
  cfg = config.marleyos.services.mopidy;
in {
  options.marleyos.services.mopidy.enable = lib.mkEnableOption "mopidy";

  config = lib.mkIf cfg.enable {
    age.secrets."mopidy-jellyfin.conf" = {
      file = ../../../secrets/mopidy-jellyfin.conf.age;
      owner = "mopidy";
      mode = "600";
    };

    services.mopidy = {
      enable = true;

      extensionPackages = with pkgs; [
        mopidy-mpd
        mopidy-jellyfin
      ];

      configuration =
        # ini
        ''
          [mpd]
          hostname = ::
        '';

      extraConfigFiles = [
        config.age.secrets."mopidy-jellyfin.conf".path
      ];
    };
  };
}
