-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.nix
33 lines (27 loc) · 848 Bytes
/
theme.nix
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
{ nixpkgs, ... }:
rec {
colors = {
main-0 = "4f46e5";
main-1 = "9333ea";
main-2 = "db2777";
bg-0 = "0c0a09";
bg-1 = "1c1917";
bg-2 = "292524";
fg-0 = "fafaf9";
fg-1 = "e7e5e4";
fg-2 = "a8a29e";
};
format = prefix: file: let
replaceWord = word: if builtins.substring 0 2 word == "__"
then let
len = builtins.stringLength word - 1;
lst = nixpkgs.lib.strings.splitString "__" (builtins.substring 2 len word);
head = nixpkgs.lib.lists.head lst;
tail = nixpkgs.lib.strings.tail lst;
in prefix + colors.${head} + (builtins.concatStringsSep "" tail)
else word;
contents = builtins.readFile file;
words = nixpkgs.lib.strings.splitString " " contents;
replacedWords = map replaceWord words;
in builtins.concatStringsSep " " replacedWords;
}