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

let cfg = config.sydnix.users.msyds.emacs.jinx;
in {
  options.sydnix.users.msyds.emacs.jinx = {
    enable = lib.mkEnableOption "Jinx spell-check";
  };

  config = lib.mkIf cfg.enable {
    sydnix.impermanence.directories =
      let xdg-config-home =
            lib.removePrefix "${config.home.homeDirectory}/"
              (lib.removePrefix "~/"
                config.xdg.configHome);
      in [ "${xdg-config-home}/enchant" ];

    sydnix.emacs.emacsPackages = epkgs: [
      epkgs.jinx
    ];
  };
}
