summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-02-05 00:47:55 +0100
committertv <tv@krebsco.de>2023-02-05 01:40:20 +0100
commit1600cd00985d819528f811d0d4d6929fd395a56d (patch)
tree972d0c1308b6d986bbacbac3c1a57bd609ac1270
parent889a27da7e532cfff95c684cc137b009545288c7 (diff)
lib.hexchars: init
-rw-r--r--lib/default.nix2
-rw-r--r--lib/genid.nix3
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 280f042..187514a 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -45,6 +45,8 @@ let
genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2;
genid_uint32 = import ./genid.nix { inherit lib; };
+ hexchars = stringToCharacters "0123456789abcdef";
+
lpad = n: c: s:
if lib.stringLength s < n
then lib.lpad n c (c + s)
diff --git a/lib/genid.nix b/lib/genid.nix
index 0aed1d3..bfa4a9a 100644
--- a/lib/genid.nix
+++ b/lib/genid.nix
@@ -32,6 +32,5 @@ let out = genid;
hexint = x: hexvals.${toLower x};
# :: attrset char uint4
- hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; })
- (stringToCharacters "0123456789abcdef"));
+ hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; }) hexchars);
in out