From a9b36cbe9292a649222b89fdb9ae9907e9c74086 Mon Sep 17 00:00:00 2001 From: Sharzy Date: Wed, 29 May 2024 05:15:11 +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 509adfa5..cce5ac19 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 ];