mirror of
https://github.com/NotAShelf/Basix.git
synced 2026-05-19 13:30:32 +00:00
nix: minor flake refactor; provide GTK and QT theme packages
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I136253e0d928e71e61824bc3f3b5a0726a6a6964
This commit is contained in:
parent
3f1f0ddc17
commit
571f60b1a0
5 changed files with 346 additions and 21 deletions
63
lib.nix
Normal file
63
lib.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{lib}: let
|
||||
requiredBaseKeys = [
|
||||
"base00"
|
||||
"base01"
|
||||
"base02"
|
||||
"base03"
|
||||
"base04"
|
||||
"base05"
|
||||
"base06"
|
||||
"base07"
|
||||
"base08"
|
||||
"base09"
|
||||
"base0A"
|
||||
"base0B"
|
||||
"base0C"
|
||||
"base0D"
|
||||
"base0E"
|
||||
"base0F"
|
||||
];
|
||||
|
||||
sanitizeSlug = slug:
|
||||
lib.strings.sanitizeDerivationName
|
||||
(lib.strings.toLower (toString slug));
|
||||
|
||||
normalizeHex = color:
|
||||
lib.strings.toLower
|
||||
(lib.removePrefix "#" (toString color));
|
||||
|
||||
missingBaseKeys = palette:
|
||||
builtins.filter (key: !(builtins.hasAttr key palette)) requiredBaseKeys;
|
||||
|
||||
validatePalette = {
|
||||
slug,
|
||||
palette,
|
||||
}: let
|
||||
missing = missingBaseKeys palette;
|
||||
in
|
||||
if missing != []
|
||||
then throw "Basix theme generation failed for `${slug}`: missing palette keys ${lib.concatStringsSep ", " missing} (required: base00-base0F)"
|
||||
else palette;
|
||||
|
||||
mkThemeName = slug: "Basix-${sanitizeSlug slug}";
|
||||
|
||||
evalSchemeData = lib.flip lib.pipe [
|
||||
builtins.unsafeDiscardStringContext
|
||||
lib.filesystem.listFilesRecursive
|
||||
(builtins.filter (lib.hasSuffix ".json"))
|
||||
(map (n: {
|
||||
name = lib.removePrefix ((dirOf n) + "/") (lib.removeSuffix ".json" n);
|
||||
value = lib.importJSON n;
|
||||
}))
|
||||
lib.listToAttrs
|
||||
];
|
||||
in {
|
||||
inherit
|
||||
evalSchemeData
|
||||
mkThemeName
|
||||
normalizeHex
|
||||
requiredBaseKeys
|
||||
sanitizeSlug
|
||||
validatePalette
|
||||
;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue