about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/firefox/lib.nix
blob: 467b9a73a5ed6e354d31d14a7c809ecc5339f5b8 (plain) (blame)
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
{lib, ...}: {
  fromHexString = hexString: let
    fromHexChar = index: char:
      {
        "0" = 0;
        "1" = 1;
        "2" = 2;
        "3" = 3;
        "4" = 4;
        "5" = 5;
        "6" = 6;
        "7" = 7;
        "8" = 8;
        "9" = 9;
        "A" = 10;
        "B" = 11;
        "C" = 12;
        "D" = 13;
        "E" = 14;
        "F" = 15;
      }
      .${lib.strings.toUpper char}
      * (
        if index == 0
        then 1
        else index * 16
      );
  in
    lib.lists.foldr (a: b: a + b) 0 (lib.lists.imap0 fromHexChar (lib.lists.reverseList (lib.strings.stringToCharacters hexString)));
}