all repos — nixfiles @ 334c968d83c5353bb80baccfb9f8d1c2daa3703c

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

user/settings/theme.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
  config,
  pkgs,
  lib,
  inputs,
  ...
}:
{
  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 = ''
      fish_config theme choose Tomorrow

      if test -e $XDG_CONFIG_HOME/.theme_history
          theme.sh (theme.sh -l | tail -n1)
      else
          theme.sh flexoki-light
      end

      function __vivid_update --on-variable VIVID_THEME
          set -gx LS_COLORS $(vivid ${
            let
              vivid = config.programs.vivid;
            in
            lib.optionalString (vivid.colorMode != null) "-m ${vivid.colorMode}"
          } generate $VIVID_THEME)
      end

      bind \co toggle-light-dark
    '';
  };

  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 = ''
      colorscheme flexoki
      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}))
          (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)))))
      '';
    };
}