{ inputs, pkgs, lib, config, ... }:
{
  /*
    imports = [
    inputs.nix-doom-emacs.hmModule
    ];
    programs.doom-emacs = {
    enable = true;
    doomPrivateDir =
    "${config.home.homeDirectory}/.doom.d";
    };
  */
  services.emacs = {
    enable = lib.mkDefault true;
    package = config.programs.emacs.finalPackage;
    client.enable = true;
    socketActivation.enable = true;
  };
  programs.emacs = {
    enable = lib.mkDefault true;
    extraPackages = epkgs: [
      epkgs.vterm
    ];
  };
  fonts.fontconfig.enable = lib.mkDefault true;
  home.packages = with pkgs; [
    # DOOM Emacs dependencies
    binutils
    (ripgrep.override { withPCRE2 = true; })
    fd
    gnutls
    hack-font
    imagemagick
    zstd
    #nodePackages.javascript-typescript-langserver
    sqlite
    #editorconfig-core-c
    emacs-all-the-icons-fonts
  ];
  home.sessionPath = [ "${config.xdg.configHome}/emacs/bin" ];
  home.sessionVariables = {
    DOOMDIR = "${config.xdg.configHome}/doom";
    DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
    DOOMPROFILELOADFILE = "${config.xdg.stateHome}/doom/load.el";
  };
  xdg.configFile = {
    "doom/cli.el".text = lib.readFile emacs/cli.el;
    "doom/config.el".text = lib.readFile emacs/config.el;
    "doom/init.el".text = lib.readFile emacs/init.el;
    "doom/packages.el".text = lib.readFile emacs/packages.el;
    "emacs" = {
      source = inputs.doom-emacs;
      onChange = "${pkgs.writeShellScript "doom-change" ''
        export DOOMDIR="${config.home.sessionVariables.DOOMDIR}"
        export DOOMLOCALDIR="${config.home.sessionVariables.DOOMLOCALDIR}"
        export DOOMPROFILELOADFILE="${config.home.sessionVariables.DOOMPROFILELOADFILE}"
        if [ ! -d "$DOOMLOCALDIR" ]; then
          ${config.xdg.configHome}/emacs/bin/doom install
        else
          ${config.xdg.configHome}/emacs/bin/doom sync -up
        fi
    ''}";
    };
  };
  xresources.properties = {
    #"Emacs.FontBackend" = "xft";
  };
}