dotfiles/modules/home/graphical/emacs.nix

223 lines
5.9 KiB
Nix
Raw Permalink Normal View History

{ pkgs, lib, config, inputs, ... }:
let
cfg = config.my.graphical.emacs;
in {
options.my.graphical.emacs = {
enable = lib.mkEnableOption null;
};
config = lib.mkIf cfg.enable (let
inherit (inputs.emacs-overlay.overlays.package null pkgs) emacsPackagesFor;
extraEpkgsMap = epkgs: extraEpkgList: map (extraEpkg: extraEpkg epkgs) extraEpkgList;
org-modern-indent = epkgs: epkgs.trivialBuild rec {
pname = "org-modern-indent";
version = "f2b859bc53107b2a1027b76dbf4aaebf14c03433";
src = pkgs.fetchFromGitHub {
owner = "jdtsmith";
repo = pname;
rev = version;
hash = "sha256-vtbaa3MURnAI1ypLueuSfgAno0l51y3Owb7g+jkK6JU=";
};
propagatedUserEnvPkgs = with epkgs; [ compat ];
buildInputs = propagatedUserEnvPkgs;
};
eglot-booster = epkgs: epkgs.trivialBuild rec {
pname = "eglot-booster";
version = "3f9159a8b7fe87e2f01280a2c4c98ca6dab49d13";
src = pkgs.fetchFromGitHub {
owner = "jdtsmith";
repo = pname;
rev = version;
hash = "sha256-yRZci0foZUw2Thx1SwSoY0iPf2DmkAnRp6U+rdx1Bas=";
};
propagatedUserEnvPkgs = [];
};
extraPackages = epkgs: with epkgs; [
f
dash
dashboard
undo-fu
god-mode
multiple-cursors
expand-region
avy
lispy
ace-window
goggles
dtrt-indent
aggressive-indent
rainbow-delimiters
highlight-indent-guides
which-key
eglot-java
yasnippet
yasnippet-snippets
consult
consult-yasnippet
embark
embark-consult
orderless
marginalia
vertico
corfu
cape
all-the-icons
all-the-icons-completion
treemacs
treemacs-all-the-icons
doom-modeline
minions
dirvish
pdf-tools
engrave-faces
org-modern
djvu
nov
pkgs.asymptote
ob-asymptote
org-pdftools
org-alert
editorconfig
envrc
sly
sly-asdf
sly-named-readtables
racket-mode
haskell-mode
lua-mode
nix-mode
gdscript-mode
markdown-mode
csv-mode
meson-mode
jinx
minimap
magit
forge
eat
mpv
lingva
mastodon
circe
circe-notifications
elfeed
xkcd
page-break-lines
hl-todo
ligature
gruvbox-theme
catppuccin-theme
solaire-mode
with-editor
nyan-mode
mu4e
org-msg
emacs-everywhere
treesit-grammars.with-all-grammars
] ++ extraEpkgsMap epkgs [
eglot-booster
org-modern-indent
];
alternateEmacsclient = pkgs.writeShellScript "alternate-emacsclient" ''
${pkgs.systemd}/bin/systemctl --user start emacs.service && \
exec ${config.programs.emacs.finalPackage}/bin/emacsclient -c -a "" "$@"
'';
in {
programs.emacs = {
enable = true;
package = (emacsPackagesFor pkgs.emacs29-pgtk).emacsWithPackages extraPackages;
};
services.emacs = {
enable = true;
startWithUserSession = "graphical";
};
home = {
sessionVariables.ALTERNATE_EDITOR = alternateEmacsclient;
packages = with pkgs; [
emacs-lsp-booster
emacs-all-the-icons-fonts
gdb
clang-tools
nil
nodePackages.typescript-language-server
ghc
stylish-haskell
haskell-language-server
hunspellDicts.en-us
imagemagick
ghostscript
(texlive.combine {
inherit (texlive) scheme-basic
dvisvgm dvipng # Preview and export as html
wrapfig amsmath ulem hyperref capt-of fontspec
# Export code with engraved backend
fvextra etoolbox fancyvrb upquote lineno
tcolorbox pgf environ pdfcol
xcolor float
nopageno
# Misc. extra stuff
apa6 breakcites apacite natbib paralist
booktabs caption threeparttable fancyhdr
geometry gettitlestring times zapfchan
asymptote
titlesec preprint marvosym enumitem metafont
;
})
pandoc
];
file.".clang-format".text = ''
---
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Always
...
'';
};
xdg.desktopEntries = let
extendDefault = lib.recursiveUpdate {
icon = "emacs";
terminal = false;
type = "Application";
settings.Keywords = "emacsclient;";
actions = {
new-window.name = "New Window";
new-instance.name = "New Instance";
};
};
in {
emacsclient = extendDefault rec {
name = "Emacs (Client)";
exec = "${config.programs.emacs.finalPackage}/bin/emacsclient -a ${alternateEmacsclient} -c %F";
genericName = "Text Editor";
comment = "Edit text";
mimeType = ["text/english" "text/plain" ];
categories = [ "Development" "TextEditor" ];
startupNotify = true;
settings.StartupWMClass = "Emacs";
actions = {
new-window = {inherit exec;};
new-instance.exec = "${config.programs.emacs.finalPackage}/bin/emacs %F";
};
};
emacsclient-mail = extendDefault rec {
name = "Emacs (Mail, Client)";
exec = (pkgs.writeShellScript "emacsclient-mail" ''
u=''${1//\\/\\\\}
u=''${u//\"/\\\"}
exec ${config.programs.emacs.finalPackage}/bin/emacsclient -a ${alternateEmacsclient} -c \
--eval "(message-mailto \"$u\")"
'') + " %u";
comment = "GNU Emacs is an extensible, customizable text editor - and more";
mimeType = [ "x-scheme-handler/mailto" ];
noDisplay = true;
actions = {
new-window = {inherit exec;};
new-instance.exec = "${config.programs.emacs.finalPackage}/bin/emacs -f message-mailto %u";
};
};
};
});
}