-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-themes.nu
executable file
·67 lines (55 loc) · 1.35 KB
/
generate-themes.nu
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
#!/usr/bin/env nu
def theme-to-nix [
theme: record # The theme to convert to Nix.
] {
$theme
| items {|key, value|
let key = match $key {
"scheme" => "name "
_ => $key
}
let value = if ($key | str starts-with "base0") {
$value | str upcase
} else {
$value
}
" " + $key + ' = "' + $value + '";'
}
| prepend "{"
| append "}\n"
| str join "\n"
}
def generate-valid-themes [] {
echo "generating themes.nix..."
ls themes
| each { |it| ' "' + ($it.name | path parse | get stem) + '" = import ./' + $it.name + ";" }
| prepend "{"
| append "}\n"
| str join "\n"
| save --force themes.nix
}
def main [] {
if not ("base16-schemes" | path exists) {
echo "base16-schemes doesn't exist, cloning..."
git clone https://github.com/tinted-theming/base16-schemes
} else {
echo "base16-schemes exists, updating"
cd base16-schemes
git pull
cd ..
}
echo "deleting old themes..."
rm -rf themes
mkdir themes
ls base16-schemes
| filter {
let extension = ($in.name | path parse | get extension)
$extension == "yml" or $extension == "yaml"
}
| each { |it|
let new_path = "themes/" + ($it.name | path parse | get stem) + ".nix"
echo $"converting ($it.name) to ($new_path)..."
theme-to-nix (open $it.name) | save $new_path
}
generate-valid-themes
}