# Obsidian knowledge base with markdown MIME association.
{
  config,
  lib,
  ...
}:
with lib; let
  cfg = config.desktop.apps.obsidian;
in {
  options.desktop.apps.obsidian.enable = mkEnableOption "enable Obsidian knowledge base";

  config = mkIf cfg.enable {
    programs.obsidian.enable = true;

    xdg.mimeApps = {
      enable = true;
      associations.added = {
        "text/markdown" = ["obsidian.desktop"];
      };
      defaultApplications = {
        "text/markdown" = ["obsidian.desktop"];
      };
    };
  };
}
