all repos — nixfiles @ 3af6f9727e1921a7a65158c407edd030b1c09edc

System and user configuration, managed by nix and home-manager

theme: extract emacs-specific theme setup

Alin
commit

3af6f9727e1921a7a65158c407edd030b1c09edc

parent

12d8af23728ccc422d0634b33301502943281c87

1 file changed, 27 insertions(+), 65 deletions(-)

changed files
M user/settings/theme.nix → user/settings/theme.nix
@@ -1,4 +1,5 @@
{ + config, pkgs, lib, ...
@@ -10,6 +11,16 @@ ppi = 72;
dpi = 96; mustFloat = x: x * 1.0; px-pt = px: (mustFloat px) * ppi / dpi; + + emacs = { + package = "base16-theme"; + light-mode-theme = "base16-flexoki-light"; + dark-mode-theme = "base16-decaf"; + minimal-user-emacs-directory = "${config.xdg.configHome}/emacs"; + config = '' + (setq base16-distinct-fringe-background nil) + ''; + }; in { # hard to find the right documentation page
@@ -106,70 +117,21 @@ dark = "Melange Dark";
}; }; - programs.emacs = - let - pname = "base16-theme"; - light-mode-theme = "base16-flexoki-light"; - dark-mode-theme = "base16-decaf"; - config = '' - (setq base16-distinct-fringe-background nil) - ''; - in - { - extraPackages = epkgs: [ - epkgs.${pname} - ]; + programs.emacs = { + extraPackages = epkgs: [ + epkgs.${emacs.package} + ]; + extraConfig = '' + (load-file "${emacs.minimal-user-emacs-directory}/theme.el") + ''; + }; - extraConfig = '' - (use-package ${pname} - :if (or (daemonp) - window-system) - :config (progn ${config})) - - (let ((light-mode-theme '${light-mode-theme}) - (dark-mode-theme '${dark-mode-theme})) - (mapc #'disable-theme custom-enabled-themes) - (load-theme light-mode-theme :noconfirm :noenable) - (load-theme dark-mode-theme :noconfirm :noenable) - - (defun my/switch-theme-variant (mode) - (interactive (list - (intern (completing-read "Make it: " '("light" "dark") nil t)))) - (cond - ((eq mode 'dark) - (disable-theme light-mode-theme) - (enable-theme dark-mode-theme)) - ((eq mode 'light) - (disable-theme dark-mode-theme) - (enable-theme light-mode-theme))) - (modify-all-frames-parameters `((ns-appearance ,mode)))) - - (defun my/system-appearance () - (if (and (eq system-type 'darwin) - (string-equal - "Dark" - (string-trim-right (shell-command-to-string "defaults read -g AppleInterfaceStyle")))) - 'dark - 'light)) - - (defun my/match-theme-system-appearance () - (interactive) - (my/switch-theme-variant (my/system-appearance))) - - (my/switch-theme-variant (my/system-appearance)) - - (use-package kqueue - :if (eq window-system 'ns) - :config (progn - (defun my/gp-notify-callback (event) - (let* ((filename (elt event 2)) - (basename (file-name-nondirectory filename))) - (when (string-equal basename ".GlobalPreferences.plist") - (my/match-theme-system-appearance)))) - (setq my/kq-watcher-global-preferences - (kqueue-add-watch (expand-file-name "~/Library/Preferences/") - '(write) - #'my/gp-notify-callback))))) - ''; - }; + xdg.configFile."emacs/theme.el".source = pkgs.replaceVars ./emacs/theme.el { + inherit (emacs) + package + config + light-mode-theme + dark-mode-theme + ; + }; }