From 09a776702b004fdf9c41a024e1299d575ee18a7d Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 23 Oct 2024 19:39:05 +0200 Subject: [PATCH] fix: avoid calling splitString ""... because it breaks evaluation on darwin with at least nix 2.18. Evaluating `lib.splitString "" "foo"` throws the following: `error: invalid regular expression ''`. We could avoid that by using lib.stringToCharacters, but as we are mapping over it anyway, lib.stringAsChars seems to be an even better fit. I tested the examples in hexEscapeUdevSymlinks docstring manually in a nix repl. --- lib/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 6cbd369..ec2c550 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -105,15 +105,12 @@ let hexEscapeUdevSymlink "all0these@char#acters+_are-allow.ed" => "all0these@char#acters+_are-allow.ed" */ - hexEscapeUdevSymlink = with lib; let + hexEscapeUdevSymlink = let allowedChars = "[0-9A-Za-z#+-.:=@_/]"; - charToHex = c: toHexString (strings.charToInt c); + charToHex = c: lib.toHexString (lib.strings.charToInt c); in - str: pipe str [ - (splitString "") - (map (c: if match allowedChars c != null || c == "" then c else "\\x" + charToHex c)) - concatStrings - ]; + lib.stringAsChars + (c: if lib.match allowedChars c != null || c == "" then c else "\\x" + charToHex c); /* get the index an item in a list