-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatppuccin-userstyles.nix
76 lines (65 loc) · 2.15 KB
/
catppuccin-userstyles.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
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
{
pkgs,
lib,
flavor ? "frappe",
accent ? "mauve",
...
}:
let
capitalizeFirst =
str:
let
first = builtins.substring 0 1 str;
rest = builtins.substring 1 (builtins.stringLength str) str;
in
(lib.strings.toUpper first) + rest;
normalizedFlavor = capitalizeFirst (
builtins.replaceStrings [ "frappe" ] [ "frappé" ] (lib.strings.toLower flavor)
);
normalizedAccent = capitalizeFirst (lib.strings.toLower accent);
in
assert
builtins.replaceStrings [ "é" ] [ "e" ] (lib.strings.toLower normalizedFlavor)
== lib.strings.toLower flavor;
assert lib.strings.toLower accent == lib.strings.toLower normalizedAccent;
pkgs.stdenvNoCC.mkDerivation (finalAttrs: {
pname = "catppuccin-userstyles";
version = "all-userstyles-export-unstable-2025-02-08";
src = pkgs.fetchFromGitHub {
owner = "catppuccin";
repo = "userstyles";
rev = "05c4dc991fa8e545ddf4504f082262841f17141c";
hash = "sha256-YSs97FB0AU6HmFO8EJLqvX8VdeZZdSPLFLdpmQtKERM=";
};
buildInputs = builtins.attrValues { inherit (pkgs) deno; };
# Set up temporary directories that Deno can write to
# See: https://docs.deno.com/runtime/getting_started/setup_your_environment/#deno_dir-environment-variable
# See: https://docs.deno.com/runtime/fundamentals/modules/#deno_dir-environment-variable
preBuild = ''
export DENO_DIR="$TMPDIR/deno"
export XDG_CACHE_HOME="$TMPDIR/cache"
export HOME="$TMPDIR/home"
mkdir -p "$DENO_DIR"
mkdir -p "$XDG_CACHE_HOME"
mkdir -p "$HOME"
'';
buildPhase = ''
runHook preBuild
rm -rf ./styles/shinigami-eyes/
rm -rf ./styles/gmail/
deno run --allow-read --allow-write --allow-net ./scripts/stylus-import/main.ts
sed -i \
-e 's/"default":"mocha"/"default":"'"${flavor}"'"/g' \
-e 's/"default":"mauve"/"default":"'"${accent}"'"/g' \
-e 's/mocha:Mocha\*"/'${flavor}':'"${normalizedFlavor}"'\*"/g' \
-e 's/mauve:Mauve\*"/'${accent}':'"${normalizedAccent}"'\*"/g' \
dist/import.json
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/dist"
cp -r "dist/import.json" $out/dist/
runHook postInstall
'';
})