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

with lib;
let
  cfg = config.my.programs.emacs;
  myEmacs = pkgs.emacsPgtkWithPackages;
in
{
  options.my.programs.emacs.enable = mkEnableOption "emacs";

  config = mkIf cfg.enable {
    my.shell.aliases = {
      emacs = "emacsclient -nw -a 'emacs -nw'";
    };
    fonts.fonts = with pkgs; [
      emacs-all-the-icons-fonts
      (iosevka-bin.override { variant = "aile"; })
    ];
    users.users.moritz.packages = [ myEmacs ];
    home-manager.users.moritz = {
      home.sessionPath = [ "/home/moritz/.config/emacs/bin/" ];
      services.emacs = {
        enable = true;
        package = myEmacs;
      };
    };
  };
}
