Skip to content

Commit

Permalink
gpg-agent: fix usage of splitString
Browse files Browse the repository at this point in the history
`splitString "" "some string"` would throw exception `error: invalid
regular expression` on Darwin (or accurately, on Nix built against
libc++). Refer to NixOS/nix#7208 for
details.

Before Nix handles that issue correctly, we should refrain from using
`splitString ""`, and luckliy `lib.stringAsChars` can do the same thing.
  • Loading branch information
SharzyL committed May 14, 2024
1 parent 44677a1 commit c38c582
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/services/gpg-agent.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ];
Expand Down

0 comments on commit c38c582

Please sign in to comment.