From c38c5822a90a760ac0f4d05054134b211f28e807 Mon Sep 17 00:00:00 2001 From: SharzyL Date: Tue, 14 May 2024 16:42:24 +0800 Subject: [PATCH] gpg-agent: fix usage of splitString `splitString "" "some string"` would throw exception `error: invalid regular expression` on Darwin (or accurately, on Nix built against libc++). Refer to https://github.com/NixOS/nix/issues/7208 for details. Before Nix handles that issue correctly, we should refrain from using `splitString ""`, and luckliy `lib.stringAsChars` can do the same thing. --- modules/services/gpg-agent.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 509adfa54609..cce5ac191041 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -48,9 +48,8 @@ let hexStringToBase32 = let mod = a: b: a - a / b * b; pow2 = elemAt [ 1 2 4 8 16 32 64 128 256 ]; - splitChars = s: init (tail (splitString "" s)); - base32Alphabet = splitChars "ybndrfg8ejkmcpqxot1uwisza345h769"; + base32Alphabet = stringToCharacters "ybndrfg8ejkmcpqxot1uwisza345h769"; hexToIntTable = listToAttrs (genList (x: { name = toLower (toHexString x); value = x; @@ -76,7 +75,7 @@ let buf = buf'; bufBits = bufBits'; }; - in hexString: (foldl' go initState (splitChars hexString)).ret; + in hexString: (foldl' go initState (stringToCharacters hexString)).ret; in { meta.maintainers = [ maintainers.rycee ];