lol
1let
2 validThemes = [ "bat" "bottom" "btop" "hyprland" "k9s" "kvantum" "lazygit" "plymouth" "refind" "rofi" "waybar" ];
3in
4{ fetchFromGitHub
5, lib
6, stdenvNoCC
7, accent ? "blue"
8, variant ? "macchiato"
9, themeList ? validThemes
10}:
11let
12 pname = "catppuccin";
13
14 validAccents = [ "rosewater" "flamingo" "pink" "mauve" "red" "maroon" "peach" "yellow" "green" "teal" "sky" "sapphire" "blue" "lavender" ];
15 validVariants = [ "latte" "frappe" "macchiato" "mocha" ];
16
17 selectedSources = map (themeName: builtins.getAttr themeName sources) themeList;
18 sources = {
19 bat = fetchFromGitHub {
20 name = "bat";
21 owner = "catppuccin";
22 repo = "bat";
23 rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1";
24 hash = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw=";
25 };
26
27 bottom = fetchFromGitHub {
28 name = "bottom";
29 owner = "catppuccin";
30 repo = "bottom";
31 rev = "c0efe9025f62f618a407999d89b04a231ba99c92";
32 hash = "sha256-VaHX2I/Gn82wJWzybpWNqU3dPi3206xItOlt0iF6VVQ=";
33 };
34
35 btop = fetchFromGitHub {
36 name = "btop";
37 owner = "catppuccin";
38 repo = "btop";
39 rev = "1.0.0";
40 hash = "sha256-J3UezOQMDdxpflGax0rGBF/XMiKqdqZXuX4KMVGTxFk=";
41 };
42
43 hyprland = fetchFromGitHub {
44 name = "hyprland";
45 owner = "catppuccin";
46 repo = "hyprland";
47 rev = "v1.2";
48 hash = "sha256-07B5QmQmsUKYf38oWU3+2C6KO4JvinuTwmW1Pfk8CT8=";
49 };
50
51 k9s = fetchFromGitHub {
52 name = "k9s";
53 owner = "catppuccin";
54 repo = "k9s";
55 rev = "516f44dd1a6680357cb30d96f7e656b653aa5059";
56 hash = "sha256-PtBJRBNbLkj7D2ko7ebpEjbfK9Ywjs7zbE+Y8FQVEfA=";
57 };
58
59 kvantum = fetchFromGitHub {
60 name = "kvantum";
61 owner = "catppuccin";
62 repo = "Kvantum";
63 rev = "d1e174c85311de9715aefc1eba4b8efd6b2730fc";
64 sha256 = "sha256-IrHo8pnR3u90bq12m7FEXucUF79+iub3I9vgH5h86Lk=";
65 };
66
67 lazygit = fetchFromGitHub {
68 name = "lazygit";
69 owner = "catppuccin";
70 repo = "lazygit";
71 rev = "0543c28e8af1a935f8c512ad9451facbcc17d8a8";
72 hash = "sha256-OVihY5E+elPKag2H4RyWiSv+MdIqHtfGNM3/1u2ik6U=";
73 };
74
75 plymouth = fetchFromGitHub {
76 name = "plymouth";
77 owner = "catppuccin";
78 repo = "plymouth";
79 rev = "d4105cf336599653783c34c4a2d6ca8c93f9281c";
80 hash = "sha256-quBSH8hx3gD7y1JNWAKQdTk3CmO4t1kVo4cOGbeWlNE=";
81 };
82
83 refind = fetchFromGitHub {
84 name = "refind";
85 owner = "catppuccin";
86 repo = "refind";
87 rev = "ff0b593c19bb9b469ee0ee36068b8d373f0fadc5";
88 hash = "sha256-itUMo0lA23bJzH0Ndq7L2IaEYoVdNPYxbB/VWkRfRso=";
89 };
90
91 rofi = fetchFromGitHub {
92 name = "rofi";
93 owner = "catppuccin";
94 repo = "rofi";
95 rev = "5350da41a11814f950c3354f090b90d4674a95ce";
96 hash = "sha256-DNorfyl3C4RBclF2KDgwvQQwixpTwSRu7fIvihPN8JY=";
97 };
98
99 waybar = fetchFromGitHub {
100 name = "waybar";
101 owner = "catppuccin";
102 repo = "waybar";
103 rev = "v1.0";
104 hash = "sha256-vfwfBE3iqIN1cGoItSssR7h0z6tuJAhNarkziGFlNBw=";
105 };
106 };
107in
108lib.checkListOfEnum "${pname}: variant" validVariants [ variant ]
109lib.checkListOfEnum "${pname}: accent" validAccents [ accent ]
110lib.checkListOfEnum "${pname}: themes" validThemes themeList
111
112stdenvNoCC.mkDerivation {
113 inherit pname;
114 version = "unstable-2023-10-09";
115
116 srcs = selectedSources;
117
118 unpackPhase = ''
119 for s in $selectedSources; do
120 b=$(basename $s)
121 cp $s ''${b#*-}
122 done
123 '';
124
125 installPhase = ''
126 runHook preInstall
127
128 local capitalizedVariant=$(sed 's/^\(.\)/\U\1/' <<< "${variant}")
129 local capitalizedAccent=$(sed 's/^\(.\)/\U\1/' <<< "${accent}")
130
131 '' + lib.optionalString (lib.elem "bat" themeList) ''
132 mkdir -p $out/bat
133 cp "${sources.bat}/Catppuccin-${variant}.tmTheme" "$out/bat/"
134
135 '' + lib.optionalString (lib.elem "btop" themeList) ''
136 mkdir -p $out/btop
137 cp "${sources.btop}/themes/catppuccin_${variant}.theme" "$out/btop/"
138
139 '' + lib.optionalString (lib.elem "bottom" themeList) ''
140 mkdir -p $out/bottom
141 cp "${sources.bottom}/themes/${variant}.toml" "$out/bottom/"
142
143 '' + lib.optionalString (lib.elem "hyprland" themeList) ''
144 mkdir -p $out/hyprland
145 cp "${sources.hyprland}/themes/${variant}.conf" "$out/hyprland/"
146
147 '' + lib.optionalString (lib.elem "k9s" themeList) ''
148 mkdir -p $out/k9s
149 cp "${sources.k9s}/dist/${variant}.yml" "$out/k9s/"
150
151 '' + lib.optionalString (lib.elem "kvantum" themeList) ''
152 mkdir -p $out/share/Kvantum
153 cp -r ${sources.kvantum}/src/Catppuccin-"$capitalizedVariant"-"$capitalizedAccent" $out/share/Kvantum
154
155 '' + lib.optionalString (lib.elem "lazygit" themeList) ''
156 mkdir -p $out/lazygit/{themes,themes-mergable}
157 cp "${sources.lazygit}/themes/${variant}/${variant}-${accent}.yml" "$out/lazygit/themes/"
158 cp "${sources.lazygit}/themes-mergable/${variant}/${variant}-${accent}.yml" "$out/lazygit/themes-mergable/"
159
160 '' + lib.optionalString (lib.elem "plymouth" themeList) ''
161 mkdir -p $out/share/plymouth/themes/catppuccin-${variant}
162 cp ${sources.plymouth}/themes/catppuccin-${variant}/* $out/share/plymouth/themes/catppuccin-${variant}
163 sed -i 's:\(^ImageDir=\)/usr:\1'"$out"':' $out/share/plymouth/themes/catppuccin-${variant}/catppuccin-${variant}.plymouth
164
165 '' + lib.optionalString (lib.elem "rofi" themeList) ''
166 mkdir -p $out/rofi
167 cp ${sources.rofi}/basic/.local/share/rofi/themes/catppuccin-${variant}.rasi $out/rofi/
168
169 '' + lib.optionalString (lib.elem "refind" themeList) ''
170 mkdir -p $out/refind/assets
171 cp ${sources.refind}/${variant}.conf $out/refind/
172 cp -r ${sources.refind}/assets/${variant} $out/refind/assets/
173
174 '' + lib.optionalString (lib.elem "waybar" themeList) ''
175 mkdir -p $out/waybar
176 cp ${sources.waybar}/${variant}.css $out/waybar/
177
178 '' + ''
179 runHook postInstall
180 '';
181
182 meta = {
183 description = "Soothing pastel themes";
184 homepage = "https://github.com/catppuccin/catppuccin";
185 license = lib.licenses.mit;
186 platforms = lib.platforms.all;
187 maintainers = [ lib.maintainers.khaneliman ];
188 };
189}