{ pkgs, ... }:
let
  emacs_pkg = ((pkgs.emacsPackagesFor pkgs.emacs30-pgtk).emacsWithPackages (
      epkgs: [
        epkgs.vterm
        epkgs.mu4e
        epkgs.sly
        epkgs.sly-quicklisp
        epkgs.geiser-racket
        epkgs.cider
        epkgs.editorconfig
        epkgs.shfmt
        epkgs.apheleia
        epkgs.parinfer-rust-mode
        epkgs.manualPackages.tree-sitter-langs
        epkgs.manualPackages.treesit-grammars.with-all-grammars
        epkgs.pretty-sha-path
        epkgs.pdf-tools
        epkgs.all-the-icons
        epkgs.eldoc
        epkgs.tablist
        epkgs.parseedn
        epkgs.parseclj
        epkgs.track-changes
      ]));
in {
  programs.emacs = {
    enable = true;
    package = emacs_pkg;
  };

  services.emacs = {
    enable = true;
    defaultEditor = true;
    package = emacs_pkg;
    socketActivation.enable = true;
    client = {
      enable = true;
      arguments = ["-n" "-r"];
    };
  };

  xdg.configFile."emacs".enable = false;

}
