{ config , pkgs , lib , ... }: let inherit (pkgs) stdenv; nativeCompileDirectory = "${config.xdg.cacheHome}/emacs/native-compile/"; darwinPath = pkgs.runCommandLocal "path_helper " { } '' eval $(/usr/libexec/path_helper) echo -n $PATH > $out ''; editorScript = pkgs.writeScriptBin "edit" '' #!${pkgs.runtimeShell} if [ -z "$1" ]; then exec ${config.programs.emacs.finalPackage}/bin/emacsclient --create-frame --alternate-editor ${config.programs.emacs.finalPackage}/bin/emacs else exec ${config.programs.emacs.finalPackage}/bin/emacsclient --alternate-editor ${config.programs.emacs.finalPackage}/bin/emacs --create-frame "$@" fi ''; desktopApplicationFile = pkgs.writeTextFile { name = "emacsclient.desktop"; destination = "/share/applications/emacsclient.desktop"; text = '' [Desktop Entry] Name=Emacsclient GenericName=Text Editor Comment=Edit text MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; Exec=${editorScript}/bin/edit %F Icon=emacs Type=Application Terminal=false Categories=Development;TextEditor; StartupWMClass=Emacs Keywords=Text;Editor; ''; }; in { imports = [ ../modules/eshell.nix ]; nixpkgs.overlays = [ (self: super: { emacsPackagesFor = emacs: (super.emacsPackagesFor emacs).overrideScope' ( eself: esuper: ( { consult-ghq = esuper.consult-ghq.overrideAttrs (oldAttrs: { src = pkgs.fetchFromGitHub { owner = "alanpearce"; repo = "consult-ghq"; rev = "3a0b366ef2e066c0d941a19d22d5a23d7f778535"; sha256 = "0v7z61nx6xyhxbqkjangqrnay7pp74w4m90wfb29l99p1wkxqbzx"; }; }); } ) ); }) ]; programs.emacs = { enable = true; package = lib.mkDefault (pkgs.emacs.override { withGTK3 = true; }); eshell = { aliases = { pk = "eshell-up-pk $1"; up = "eshell-up $1"; ec = "find-file $1"; l = "ls $*"; la = "ls -A $*"; ll = "ls -lh $*"; lla = "ls -lhA $*"; http = "xh"; https = "xh --default-scheme https $*"; xhs = "xh --default-scheme https $*"; ava = "npx ava $*"; bunyan = "npx bunyan $*"; mocha = "npx mocha $*"; standard = "npx standard $*"; tsc = "npx tsc $*"; tslnt = "npx tslnt $*"; tsnode = "npx tsnode $*"; kx = "kubectx $*"; kns = "kubens $*"; cdg = "cd (project-root)"; }; }; extraPackages = epkgs: (with epkgs; [ ace-link apheleia avy capf-autosuggest clojure-mode company company-posframe company-shell company-tabnine consult consult-ghq # own override consult-eglot crux dired-git-info docker-compose-mode dockerfile-mode envrc editorconfig eglot eldoc-box emacs-gc-stats esh-buf-stack esh-help eshell-fringe-status eshell-toggle eshell-up evil evil-anzu evil-collection evil-commentary evil-embrace evil-matchit evil-mu4e evil-numbers evil-org evil-quickscope evil-space evil-surround evil-textobj-tree-sitter eyebrowse format-all flycheck flyspell-correct flyspell-correct-avy-menu general git-gutter-fringe git-messenger git-modes git-timemachine goto-chg helpful jinx just-mode justl json-mode lua-mode lispy lispyville magit magit-filenotify markdown-mode marginalia nerd-icons doom-modeline posframe quickrun rainbow-mode rainbow-delimiters stimmung-themes toml-mode tree-sitter tree-sitter-langs tree-sitter-indent use-package vertico vertico-prescient wgrep-ag ws-butler which-key yaml-mode ]); extraConfig = '' (with-eval-after-load 'editorconfig (setq editorconfig-exec-path "${pkgs.editorconfig-core-c}/bin/editorconfig")) (setq native-compile-target-directory "${nativeCompileDirectory}") (add-to-list 'native-comp-eln-load-path "${nativeCompileDirectory}" :append) '' + lib.optionalString stdenv.isDarwin '' (with-eval-after-load 'files (setq insert-directory-program "${pkgs.coreutils-prefixed}/bin/gls")) (with-eval-after-load 'dired (setq dired-use-ls-dired t)) (setq exec-path (parse-colon-path (setenv "PATH" "${pkgs.lib.readFile darwinPath}"))) ''; }; home.packages = with pkgs; [ editorScript # see https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/data/fonts/nerdfonts/shas.nix (nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" "JetBrainsMono" "IBMPlexMono" "iA-Writer" ]; }) ]; xdg.configFile."emacs/early-init.el" = { source = ../emacs/early-init.el; }; xdg.configFile."emacs/init.el" = { source = ../emacs/init.el; }; home.file.".local/share/applications/emacsclient.desktop" = lib.mkIf stdenv.isLinux { source = desktopApplicationFile; }; }