{ config
, lib
, pkgs
, ...
}:

with lib;
let
  cfg = config.my.programs.spotify-player;
  toml = pkgs.formats.toml { };
in
{
  options.my.programs.spotify-player = {
    enable = mkEnableOption "spotify-player";
    package = mkOption {
      type = types.package;
      default = pkgs.spotify-player;
    };
    config = mkOption {
      inherit (toml) type;
      default = { };
    };
  };

  config = mkIf cfg.enable {
    home-manager.users.moritz = {
      xdg.configFile."spotify-player/app.toml" = {
        source = toml.generate "app.toml" cfg.config;
      };
      home.packages = [ cfg.package ];
    };
  };
}
