From 326d0970e067da3577b353c20cde29fc22a77265 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Wed, 14 Apr 2021 12:02:36 +0200 Subject: [PATCH 1/2] lib/strings: fix example for isStorePath Since it checks if dirOf x is the nix store dir, a trailing slash will break this check and make it return false. --- lib/strings.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/strings.nix b/lib/strings.nix index 2e502588bf80..dc287f8dd5cb 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -659,7 +659,7 @@ rec { Example: isStorePath "/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11/bin/python" => false - isStorePath "/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11/" + isStorePath "/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11" => true isStorePath pkgs.python => true From f39a5c4e50c3f0dfb108b399c2da2c963d4d1a98 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 4 May 2021 15:07:56 +0200 Subject: [PATCH 2/2] lib/strings: forbid lists in isStorePath When a list is passed to isStorePath this is most likely a mistake and it is therefore better to just return false. There is one case where this theoretically makes sense (if a list contains a single element for which isStorePath elem), but since that case is also probably seldomly intentional, it may save someone from debbuging unclear evaluation errors. --- lib/strings.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/strings.nix b/lib/strings.nix index dc287f8dd5cb..49fa0196a0b2 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -667,7 +667,7 @@ rec { => false */ isStorePath = x: - if isCoercibleToString x then + if !(isList x) && isCoercibleToString x then let str = toString x; in substring 0 1 str == "/" && dirOf str == storeDir