theme: init module
1 file changed, 167 insertions(+), 0 deletions(-)
changed files
A user/settings/theme.nix
@@ -0,0 +1,167 @@ +{ + pkgs, + inputs, + ... +}: +let + +in +{ + nixpkgs.overlays = [ + (final: prev: { + theme-sh = prev.theme-sh.overrideAttrs { + patchPhase = '' + install -Dt custom ${inputs.flexoki}/theme.sh/flexoki-{light,dark} + bin/theme.sh -a custom/* + ''; + }; + }) + ]; + home.packages = with pkgs; [ + theme-sh + ]; + + xdg.configFile = { + "fish.themes/flexoki-light".source = "${inputs.flexoki}/fish/flexoki-light.theme"; + "fish.themes/flexoki-dark".source = "${inputs.flexoki}/fish/flexoki-dark.theme"; + }; + + programs.fzf.colors = { + "fg" = "#B7B5AC"; + "bg" = "#FFFCF0"; + "hl" = "#100F0F"; + "fg+" = "#B7B5AC"; + "bg+" = "#F2F0E5"; + "hl+" = "#100F0F"; + "border" = "#AF3029"; + "header" = "#100F0F"; + "gutter" = "#FFFCF0"; + "spinner" = "#3AA99F"; + "info" = "#3AA99F"; + "separator" = "#F2F0E5"; + "pointer" = "#D0A215"; + "marker" = "#D14D41"; + "prompt" = "#D0A215"; + }; + + programs.fish = { + shellAliases.theme = "theme.sh"; + + loginShellInit = '' + if test -e $XDG_CONFIG_HOME/.theme_history + theme.sh (theme.sh -l | tail -n1) + else + theme.sh flexoki-light + end + + # Optional + # Bind C-o to the last theme. + function last_theme + theme.sh (theme.sh -l | tail -n2 | head -n1) + end + + bind \co last_theme + ''; + }; + + programs.vivid.activeTheme = "gruvbox-light"; # TODO add flexoki + + programs.nixvim = { + extraPlugins = [ + (pkgs.vimUtils.buildVimPlugin { + name = "flexoki-neovim"; + src = pkgs.fetchFromGitHub { + owner = "kepano"; + repo = "flexoki-neovim"; + rev = "c3e2251e813d29d885a7cbbe9808a7af234d845d"; + hash = "sha256-TlBP99MBAT/H0Uut1MF8SnIDoeetcdHLKrWal2oO2Ug="; + }; + }) + ]; + extraConfigVim = '' + set notermguicolors + colorscheme flexoki-light + highlight Search ctermfg=0 + ''; + + colorschemes = { + melange.enable = true; + }; + }; + + programs.zed-editor = { + extensions = [ "flexoki-themes" ]; + userSettings.theme = { + light = "Flexoki Light"; + dark = "Flexoki Dark"; + }; + }; + + programs.emacs = + let + pname = "flexoki-themes"; + light-mode-theme = "flexoki-themes-light"; + dark-mode-theme = "flexoki-themes-dark"; + config = '' + ;; (flexoki-themes-use-bold-keywords t) + ;; (flexoki-themes-use-bold-builtins t) + ;; (flexoki-themes-use-italic-comments t) + ''; + in + { + extraPackages = epkgs: [ + epkgs.${pname} + ]; + + 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})) + (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))))) + ''; + }; +}