{ lib, ... }: let enableEmacs = true; # Toggle to enable/disable Emacs module in { # Top-level option to enable Emacs options.enableEmacs = lib.mkEnableOption "Enable Emacs configuration"; # Module configuration wrapped safely with mkIf config = lib.mkIf enableEmacs { myApps = { emacs = { enable = true; # Home Manager user (top-level default can be used) user = config.defaultUser or "henrov"; # Emacs package specification and extra packages package = { name = "emacs-pgtk"; withTreeSitter = true; }; extraPackages = [ # Tree-sitter and language support "manualPackages.treesit-grammars.with-all-grammars" "rust-mode" "rustic" "nix-mode" "hcl-mode" # UI/UX and navigation "nerd-icons" "doom-modeline" "diminish" "eldoc" "eldoc-box" "pulsar" "which-key" "avy" "consult" "vertico" "marginalia" "crux" "shell-pop" # Completion and snippets "nerd-icons-corfu" "corfu" "cape" "orderless" "yasnippet" "yasnippet-snippets" # Utilities and tools "rg" "exec-path-from-shell" "eat" "f" "gptel" "nixpkgs-fmt" "envrc" # Theming "catppuccin-theme" # Git "magit" # Editing and workflow "expreg" "vundo" "puni" # Error and side panel support "sideline" "sideline-flymake" "sideline-eglot" ]; # Optional environment/session variables sessionVariables = { EDITOR = "emacs"; XDG_SCREENSHOTS_DIR = "~/screenshots"; }; }; }; }; }