From ccfa6b3eee9f5e613152a4b373f67ff05696adf8 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Mon, 15 Jun 2020 16:12:27 +0200
Subject: [PATCH] Give better error message about <...> in pure eval mode

---
 src/libexpr/parser.y | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index a1188dec0..a639be64e 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -689,7 +689,10 @@ Path EvalState::findFile(SearchPath & searchPath, const string & path, const Pos
         if (pathExists(res)) return canonPath(res);
     }
     throw ThrownError({
-        .hint = hintfmt("file '%1%' was not found in the Nix search path (add it using $NIX_PATH or -I)", path),
+        .hint = hintfmt(evalSettings.pureEval
+            ? "cannot look up '<%s>' in pure evaluation mode (use '--impure' to override)"
+            : "file '%s' was not found in the Nix search path (add it using $NIX_PATH or -I)",
+            path),
         .nixCode = NixCode { .errPos = pos }
     });
 }
-- 
GitLab