From de81edf6ef023d45d32c024d8be272d0d2eb343b Mon Sep 17 00:00:00 2001 From: polykernel <81340136+polykernel@users.noreply.github.com> Date: Thu, 26 Aug 2021 19:54:30 -0400 Subject: [PATCH] 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. --- lib/strings.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/strings.nix b/lib/strings.nix index 86c92bdaa15..a111e1e2597 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -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