summary refs log tree commit diff
path: root/lib/strings.nix
diff options
context:
space:
mode:
authorpolykernel <81340136+polykernel@users.noreply.github.com>2021-08-26 19:54:30 -0400
committerpolykernel <81340136+polykernel@users.noreply.github.com>2021-08-26 20:08:05 -0400
commitde81edf6ef023d45d32c024d8be272d0d2eb343b (patch)
tree0561bbb743c4cb339e30838a2cd786b289fcdfb6 /lib/strings.nix
parent7f70726259f53d9d23fa1ee725474fa60a9b83b7 (diff)
downloadnixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.tar
nixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.tar.gz
nixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.tar.bz2
nixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.tar.lz
nixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.tar.xz
nixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.tar.zst
nixpkgs-de81edf6ef023d45d32c024d8be272d0d2eb343b.zip
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.
Diffstat (limited to 'lib/strings.nix')
-rw-r--r--lib/strings.nix2
1 files changed, 1 insertions, 1 deletions
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