lib/strings: fix infinite recursion on concatStringsSep fallback

The current implementation of the concatStringsSep fallback references
concatStrings whcih is just a partial application of concatStringsSep,
forming a circular dependency. Although this will almost never be
encountered as (assuming the user does not explicitly trigger it):
  1. the or operator will short circuit both in lazy and strict
     evaluation
  2. this can only occur in Nix versions prior to 1.10
     which is not compatible with various nix operations as of 2.3.15

However it is still important if scopedImport is used or the builtins
have been overwritten. lib.foldl' is used instead of builtins.foldl'
as the foldl' primops was introduced in the same release as concatStringsSep.
This commit is contained in:
polykernel 2021-08-26 19:54:30 -04:00
parent 7f70726259
commit de81edf6ef

View File

@ -89,7 +89,7 @@ rec {
=> "usr/local/bin"
*/
concatStringsSep = builtins.concatStringsSep or (separator: list:
concatStrings (intersperse separator list));
lib.foldl' (x: y: x + y) "" (intersperse separator list));
/* Maps a function over a list of strings and then concatenates the
result with the specified separator interspersed between