{ lib, pkgs, config, ... }: let moduleName = "emacs"; username = config.defaultUser or "henrov"; # Paths to your init files (relative to this module) emacsAssets = ../../../assets/system/conf/emacs; initFile = "${emacsAssets}/init.el"; earlyInitFile = "${emacsAssets}/early-init.el"; # Toggle for this module enableProgram = config.enableEmacs or false; in { # Top-level toggle option options.enableEmacs = lib.mkEnableOption "Enable Emacs configuration"; config = lib.mkIf enableProgram { # Minimal system-wide Emacs package environment.systemPackages = [ pkgs.emacs-pgtk.override { withTreeSitter = true; } ]; # Home Manager Emacs config home-manager.users.${username} = { programs.emacs = { enable = true; package = pkgs.emacs-pgtk.override { withTreeSitter = true; }; extraPackages = epkgs: with epkgs; [ # Core dev and language support manualPackages.treesit-grammars.with-all-grammars rust-mode rustic nix-mode hcl-mode # UI & workflow nerd-icons doom-modeline diminish eldoc eldoc-box pulsar which-key avy consult vertico marginalia crux shell-pop # Completion/snippets nerd-icons-corfu corfu cape orderless yasnippet yasnippet-snippets # Utilities rg exec-path-from-shell eat f gptel nixpkgs-fmt envrc # Theming catppuccin-theme # Git magit # Editing/workflow expreg vundo puni # Error/side panels sideline sideline-flymake sideline-eglot ]; # Load your init files from assets initFile = initFile; earlyInitFile = earlyInitFile; }; # Useful session variables home.sessionVariables = { EDITOR = "emacs"; XDG_SCREENSHOTS_DIR = "~/screenshots"; }; }; }; }