mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 16:57:55 +00:00
46 lines
1.3 KiB
Nix
46 lines
1.3 KiB
Nix
{ pkgs, lib }:
|
|
|
|
let
|
|
isBaseX = i: palette:
|
|
let
|
|
paletteNames = pkgs.lib.attrNames palette;
|
|
maxDigitLength = pkgs.lib.lists.length (pkgs.lib.toBaseDigits 10 i);
|
|
mkBaseAttr = hex: "base${lib.hex.pad maxDigitLength hex}";
|
|
schemeNames = builtins.map mkBaseAttr (lib.hex.range 0 (i - 1));
|
|
in
|
|
(pkgs.lib.count (name: pkgs.lib.elem name schemeNames) paletteNames) == i;
|
|
in
|
|
{
|
|
# TODO: Return a Nix object to generate a Tinted Theming color scheme from an
|
|
# image.
|
|
generateScheme = image: { };
|
|
|
|
/* A very naive implementation of checking whether the given palette is a
|
|
valid Base16 palette. It simply checks if `base00` to `base0F` is present.
|
|
|
|
Type: isBase16 :: Attrs -> Bool
|
|
|
|
Example:
|
|
isBase16 (bahaghariLib.importYAML ./base16.yml).palette
|
|
=> true
|
|
|
|
isBase16 (bahaghariLib.importYAML ./base16-scheme-with-missing-base0F.yml).palette
|
|
=> false
|
|
*/
|
|
isBase16 = isBaseX 16;
|
|
|
|
/* Similar to `isBase16` but for Base24 schemes. It considers the scheme as
|
|
valid if `base00` to `base17` from the palette are present.
|
|
|
|
Type: isBase24 :: Attrs -> Bool
|
|
|
|
Example:
|
|
isBase24 (bahaghariLib.importYAML ./base24.yml).palette
|
|
=> true
|
|
|
|
isBase24 (bahaghariLib.importYAML ./base24-scheme-with-missing-base0F.yml).palette
|
|
=> false
|
|
*/
|
|
isBase24 = isBaseX 24;
|
|
}
|