diff --git a/system/home/emacs/default.nix b/system/home/emacs/default.nix index 3f8c0a01..98d4529f 100644 --- a/system/home/emacs/default.nix +++ b/system/home/emacs/default.nix @@ -5,7 +5,6 @@ ../shell/git.nix ../gpg/default.nix ]; - stylix.targets.emacs.enable = false; services.emacs = { enable = true; package = config.programs.emacs.finalPackage; @@ -21,47 +20,12 @@ withImageMagick = true; withPgtk = true; }; - extraConfig = - let - fixed-font-family = "${config.stylix.fonts.monospace.name}"; - variable-font-family = "${config.stylix.fonts.sansSerif.name}"; - font-height = builtins.toString ( - builtins.floor (builtins.mul config.stylix.fonts.sizes.applications 10) - ); - custom-theme-name = "nix"; - custom-theme = pkgs.writeTextFile { - name = "custom-emacs-theme"; - destination = "/${custom-theme-name}-theme.el"; - text = '' - (deftheme ${custom-theme-name} - "Use Nix customised fonts for main faces") - - (custom-theme-set-variables - '${custom-theme-name} - '(menu-bar-mode nil)) - - (custom-theme-set-faces - '${custom-theme-name} - '(default ((t (:family "${fixed-font-family}" :height ${font-height})))) - '(fixed-pitch ((t (:family "${fixed-font-family}")))) - '(fixed-pitch-serif ((t (:family "${fixed-font-family}")))) - '(variable-pitch ((t (:family "${variable-font-family}"))))) - - (provide-theme '${custom-theme-name}) - ''; - }; - custom-theme-hash = builtins.hashFile "sha256" "${custom-theme}/${custom-theme-name}-theme.el"; - in - '' - (add-to-list 'custom-theme-load-path "${custom-theme}") - (add-to-list 'custom-safe-themes "${custom-theme-hash}") - (load-theme '${custom-theme-name}) - ''; + extraConfig = builtins.readFile ./extraConfig.el; extraPackages = epkgs: with epkgs; [ treesit-grammars.with-all-grammars - mu4e emacsql-sqlite + mu4e ]; }; home.packages = with pkgs; [ diff --git a/system/home/emacs/extraConfig.el b/system/home/emacs/extraConfig.el new file mode 100644 index 00000000..be0fb977 --- /dev/null +++ b/system/home/emacs/extraConfig.el @@ -0,0 +1,42 @@ +(defun my/configure-theme () + "Load theme and configure some faces." + (interactive) + + ;; Set some font-lock faces to be italic + (set-face-attribute 'font-lock-doc-face nil :slant 'italic) + (set-face-attribute 'font-lock-comment-face nil :slant 'italic) + (set-face-attribute 'font-lock-comment-delimiter-face nil :slant 'italic) + + ;; Change outline headers to follow rainbow order + (require 'outline) + (when (boundp 'base16-stylix-theme-colors) + (dolist (pairing '((outline-1 . :base08) + (outline-2 . :base09) + (outline-3 . :base0A) + (outline-4 . :base0B) + (outline-5 . :base0C) + (outline-6 . :base0D) + (outline-7 . :base0E) + (outline-8 . :base0F))) + (set-face-attribute (car pairing) nil + :foreground + (plist-get base16-stylix-theme-colors (cdr pairing)))) + + (require 'org-faces) + ;; Lighten `org-agenda-clocking' background to be more legible. + (set-face-attribute 'org-agenda-clocking nil :background + (plist-get base16-stylix-theme-colors :base01)) + ;; Set `org-hide' face to actually match background colour + (set-face-attribute 'org-hide nil :foreground + (plist-get base16-stylix-theme-colors :base00)) + (with-eval-after-load 'org-noter + (set-face-attribute 'org-noter-no-notes-exist-face nil :foreground + (plist-get base16-stylix-theme-colors :base08)) + (set-face-attribute 'org-noter-notes-exist-face nil :foreground + (plist-get base16-stylix-theme-colors :base0B)))) + ) + +(with-eval-after-load 'base16-theme + (require 'server) + (add-hook 'after-init-hook (lambda () (my/configure-theme))) + (add-hook 'server-after-make-frame-hook (lambda () (my/configure-theme))))