feat(emacs): robust Nix-based Emacs setup with daemon service, improved elisp dev, and full package documentation
- Emacs daemon runs as a systemd service via Nix - Modular Emacs config with Nix-managed packages (elisp-slime-nav, aggressive-indent, highlight-defined, etc.) - Keybinding fixes and error handling improvements - New EMACS_README.md explains ecosystem and troubleshooting - Nix config: GUI sudo askpass, podman, and desktop tweaks - All errors from missing packages and keybindings resolved
This commit is contained in:
parent
649f0f3b2c
commit
251222037d
7 changed files with 132 additions and 10 deletions
|
@ -25,7 +25,7 @@
|
||||||
(menu-bar-mode -1)
|
(menu-bar-mode -1)
|
||||||
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
||||||
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
|
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
|
||||||
(set-face-attribute 'default nil :height 140)
|
(set-face-attribute 'default nil :height 100)
|
||||||
(setq-default cursor-type 'bar)
|
(setq-default cursor-type 'bar)
|
||||||
|
|
||||||
;; Nix Integration Setup
|
;; Nix Integration Setup
|
||||||
|
@ -93,6 +93,26 @@
|
||||||
(package-refresh-contents)
|
(package-refresh-contents)
|
||||||
(package-install 'use-package)))
|
(package-install 'use-package)))
|
||||||
|
|
||||||
|
;; Quelpa setup for packages not available in standard repos
|
||||||
|
(unless (package-installed-p 'quelpa)
|
||||||
|
(with-temp-buffer
|
||||||
|
(url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")
|
||||||
|
(eval-buffer)
|
||||||
|
(quelpa-self-upgrade)))
|
||||||
|
|
||||||
|
;; Install quelpa-use-package for integration
|
||||||
|
(unless (package-installed-p 'quelpa-use-package)
|
||||||
|
(quelpa 'quelpa-use-package))
|
||||||
|
(require 'quelpa-use-package)
|
||||||
|
|
||||||
|
;; Install eat terminal emulator (not available in standard repos)
|
||||||
|
(unless (package-installed-p 'eat)
|
||||||
|
(quelpa '(eat :fetcher git
|
||||||
|
:url "https://codeberg.org/akib/emacs-eat.git"
|
||||||
|
:files ("*.el" "dir"
|
||||||
|
"*.info" "*.texi"
|
||||||
|
"*.ti" ("e" "e/*")))))
|
||||||
|
|
||||||
;; Configure use-package for Nix integration
|
;; Configure use-package for Nix integration
|
||||||
(require 'use-package)
|
(require 'use-package)
|
||||||
;; Don't auto-install packages in Nix environment - they're pre-provided
|
;; Don't auto-install packages in Nix environment - they're pre-provided
|
||||||
|
|
|
@ -96,12 +96,12 @@
|
||||||
(claude-code-send-command
|
(claude-code-send-command
|
||||||
(format "I'm getting an error around line %d. Here's the context:\n\n```%s\n%s\n```\n\nCan you help me fix this?"
|
(format "I'm getting an error around line %d. Here's the context:\n\n```%s\n%s\n```\n\nCan you help me fix this?"
|
||||||
error-line
|
error-line
|
||||||
(or (file-name-extension (buffer-file-name)) "")
|
(or (and buffer-file-name (file-name-extension buffer-file-name)) "")
|
||||||
context)))
|
context)))
|
||||||
(message "Claude Code is not running. Start it with C-c C-c c")))
|
(message "Claude Code is not running. Start it with C-c C-c c")))
|
||||||
|
|
||||||
;; Keybinding for enhanced error context
|
;; Keybinding for enhanced error context
|
||||||
(global-set-key (kbd "C-c C-c x") #'claude-code-send-error-context)
|
(global-set-key (kbd "C-c c x") #'claude-code-send-error-context)
|
||||||
|
|
||||||
;; Project-aware Claude instances
|
;; Project-aware Claude instances
|
||||||
(defun claude-code-project-instance ()
|
(defun claude-code-project-instance ()
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
(claude-code)))
|
(claude-code)))
|
||||||
|
|
||||||
;; Keybinding for project-specific Claude
|
;; Keybinding for project-specific Claude
|
||||||
(global-set-key (kbd "C-c C-c p") #'claude-code-project-instance)
|
(global-set-key (kbd "C-c c p") #'claude-code-project-instance)
|
||||||
|
|
||||||
(provide 'claude-code)
|
(provide 'claude-code)
|
||||||
;;; claude-code.el ends here
|
;;; claude-code.el ends here
|
||||||
|
|
|
@ -160,9 +160,10 @@
|
||||||
;; Better compilation output
|
;; Better compilation output
|
||||||
(add-hook 'emacs-lisp-mode-hook
|
(add-hook 'emacs-lisp-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(setq-local compile-command
|
(when buffer-file-name
|
||||||
(format "emacs -batch -f batch-byte-compile %s"
|
(setq-local compile-command
|
||||||
(shell-quote-argument buffer-file-name)))))
|
(format "emacs -batch -f batch-byte-compile %s"
|
||||||
|
(shell-quote-argument buffer-file-name))))))
|
||||||
|
|
||||||
(provide 'elisp-development)
|
(provide 'elisp-development)
|
||||||
;;; elisp-development.el ends here
|
;;; elisp-development.el ends here
|
||||||
|
|
|
@ -34,9 +34,7 @@
|
||||||
../../modules/users/shell-aliases.nix
|
../../modules/users/shell-aliases.nix
|
||||||
|
|
||||||
# Virtualization
|
# Virtualization
|
||||||
# ../../modules/virtualization/libvirt.nix
|
../../modules/virtualization/podman.nix
|
||||||
# ../../modules/virtualization/incus.nix
|
|
||||||
# ../../modules/virtualization/podman.nix
|
|
||||||
|
|
||||||
# Audio
|
# Audio
|
||||||
../../modules/sound/pipewire.nix
|
../../modules/sound/pipewire.nix
|
||||||
|
|
|
@ -26,6 +26,14 @@
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
firefox
|
firefox
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# GUI sudo askpass helper for desktop environments
|
||||||
|
programs.ssh.askPassword = "${pkgs.libsForQt5.ksshaskpass}/bin/ksshaskpass";
|
||||||
|
security.sudo.extraConfig = ''
|
||||||
|
Defaults env_keep += "SSH_ASKPASS"
|
||||||
|
'';
|
||||||
|
environment.variables.SUDO_ASKPASS = "${pkgs.libsForQt5.ksshaskpass}/bin/ksshaskpass";
|
||||||
|
|
||||||
# Flatpak support
|
# Flatpak support
|
||||||
services.flatpak.enable = true;
|
services.flatpak.enable = true;
|
||||||
}
|
}
|
||||||
|
|
91
modules/development/EMACS_README.md
Normal file
91
modules/development/EMACS_README.md
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
# Emacs + Nix Setup: Overview and Package Guide
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
This document explains the Emacs ecosystem and the Nix-based configuration used in this project. It covers the purpose of key Emacs packages, how they are managed with Nix, and how to extend or troubleshoot your setup.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Why Use Nix for Emacs?
|
||||||
|
|
||||||
|
- **Reproducibility:** Nix ensures your Emacs environment is consistent across machines and rebuilds.
|
||||||
|
- **Declarative Configuration:** All packages and dependencies are listed in a single place (`emacs.nix`), making it easy to update or share.
|
||||||
|
- **Isolation:** Nix prevents conflicts between Emacs packages and system/global packages.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Emacs Packages in This Setup
|
||||||
|
|
||||||
|
### Navigation & Completion
|
||||||
|
|
||||||
|
- **vertico, consult, marginalia, orderless, embark, embark-consult, corfu, cape:** Modern completion and minibuffer enhancements for fast, fuzzy, and context-aware navigation.
|
||||||
|
- **projectile:** Project management and navigation.
|
||||||
|
|
||||||
|
### Version Control
|
||||||
|
|
||||||
|
- **magit:** The best Git interface for Emacs.
|
||||||
|
- **forge:** GitHub/GitLab/Magit integration for issues and pull requests.
|
||||||
|
|
||||||
|
### Development Tools
|
||||||
|
|
||||||
|
- **lsp-mode, lsp-ui:** Language Server Protocol support for IDE-like features.
|
||||||
|
- **company:** In-buffer code completion.
|
||||||
|
- **flycheck:** On-the-fly syntax checking.
|
||||||
|
- **yasnippet:** Snippet expansion for faster coding.
|
||||||
|
- **elisp-slime-nav:** Easy navigation of Emacs Lisp code.
|
||||||
|
- **aggressive-indent:** Keeps your code automatically indented.
|
||||||
|
- **highlight-defined:** Highlights defined symbols in Emacs Lisp.
|
||||||
|
|
||||||
|
### Language Support
|
||||||
|
|
||||||
|
- **nix-mode:** Nix language editing.
|
||||||
|
- **rust-mode, python-mode, typescript-mode, json-mode, yaml-mode, markdown-mode:** Major modes for popular languages and formats.
|
||||||
|
- **elisp-ls:** Emacs Lisp Language Server for LSP features in Emacs Lisp.
|
||||||
|
|
||||||
|
### Org & Knowledge Management
|
||||||
|
|
||||||
|
- **org, org-roam, org-roam-ui:** Org-mode for notes, tasks, and literate programming; org-roam for Zettelkasten-style knowledge management.
|
||||||
|
|
||||||
|
### UI & Usability
|
||||||
|
|
||||||
|
- **doom-themes, doom-modeline, all-the-icons, rainbow-delimiters, highlight-indent-guides:** Visual enhancements for a modern, readable Emacs.
|
||||||
|
- **smartparens, expand-region, multiple-cursors, avy, ace-window:** Editing and navigation power tools.
|
||||||
|
- **vterm:** Terminal emulator inside Emacs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## How the Nix Setup Works
|
||||||
|
|
||||||
|
- The file `modules/development/emacs.nix` defines a function that builds a custom Emacs with all the above packages.
|
||||||
|
- Packages are grouped by purpose (essential, minimal, development, workstation) and selected based on your machine profile.
|
||||||
|
- When you rebuild your system or run `nix develop`, Nix fetches and builds all required Emacs packages.
|
||||||
|
- Environment variables (like `AG_PATH`, `FD_PATH`, etc.) are set for Emacs to use external tools.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Extending Your Setup
|
||||||
|
|
||||||
|
- To add a new package, add it to the appropriate list in `emacs.nix` (e.g., under `development = epkgs: with epkgs; [ ... ]`).
|
||||||
|
- Rebuild your system or development shell to apply changes.
|
||||||
|
- For packages not in Nixpkgs, consider using MELPA as a fallback, but prefer Nix for reproducibility.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
- If you see `Cannot open load file` errors, make sure the package is included in your Nix config.
|
||||||
|
- For missing language servers, check if the correct Nix package is used (e.g., `elisp-ls` for Emacs Lisp LSP).
|
||||||
|
- Use `emacs --daemon --debug-init` to debug startup issues.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
- [NixOS Emacs Wiki](https://nixos.wiki/wiki/Emacs)
|
||||||
|
- [Emacs Manual](https://www.gnu.org/software/emacs/manual/)
|
||||||
|
- [Nixpkgs Emacs Packages](https://search.nixos.org/packages?channel=unstable&show=emacsPackages)
|
||||||
|
- [System Crafters: Emacs from Scratch](https://systemcrafters.net/)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
This setup gives you a modern, reproducible, and powerful Emacs environment managed entirely by Nix. Happy hacking!
|
|
@ -75,6 +75,7 @@ with lib; let
|
||||||
json-mode
|
json-mode
|
||||||
yaml-mode
|
yaml-mode
|
||||||
markdown-mode
|
markdown-mode
|
||||||
|
lsp-scheme
|
||||||
|
|
||||||
# Org mode and knowledge management
|
# Org mode and knowledge management
|
||||||
org
|
org
|
||||||
|
@ -82,6 +83,7 @@ with lib; let
|
||||||
org-roam-ui
|
org-roam-ui
|
||||||
|
|
||||||
# UI enhancements
|
# UI enhancements
|
||||||
|
highlight-defined
|
||||||
doom-themes
|
doom-themes
|
||||||
doom-modeline
|
doom-modeline
|
||||||
all-the-icons
|
all-the-icons
|
||||||
|
@ -89,6 +91,8 @@ with lib; let
|
||||||
highlight-indent-guides
|
highlight-indent-guides
|
||||||
|
|
||||||
# Editing enhancements
|
# Editing enhancements
|
||||||
|
elisp-slime-nav
|
||||||
|
aggressive-indent
|
||||||
smartparens
|
smartparens
|
||||||
expand-region
|
expand-region
|
||||||
multiple-cursors
|
multiple-cursors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue