Move Emacs font settings to theme, which is then loaded in extraConfig

This commit is contained in:
Evie Litherland-Smith 2024-06-20 16:25:50 +01:00
parent 9626796c46
commit ab7790b983

View file

@ -23,20 +23,31 @@
enable = true;
package = pkgs.emacs29-pgtk;
extraConfig = let
shell = "${pkgs.zsh}/bin/zsh";
font = "${fonts.monospace.name}-${toString fonts.sizes.applications}";
fixed-font-family = "${fonts.monospace.name}";
variable-font-family = "${fonts.sansSerif.name}";
alpha = "100"; # "90";
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-faces
'${custom-theme-name}
'(default ((t (:family "${fixed-font-family}" :height 120))))
'(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 ''
(customize-set-variable 'shell-file-name "${shell}")
(add-to-list 'initial-frame-alist '(font . "${font}"))
(add-to-list 'default-frame-alist '(font . "${font}"))
(set-face-attribute 'fixed-pitch nil :family "${fixed-font-family}")
(set-face-attribute 'fixed-pitch-serif nil :family "${fixed-font-family}")
(set-face-attribute 'variable-pitch nil :family "${variable-font-family}")
(add-to-list 'initial-frame-alist '(alpha-background . ${alpha}))
(add-to-list 'default-frame-alist '(alpha-background . ${alpha}))
(add-to-list 'custom-theme-load-path "${custom-theme}")
(add-to-list 'custom-safe-themes "${custom-theme-hash}")
(load-theme '${custom-theme-name})
'';
extraPackages = epkgs:
with epkgs; [