aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorBas van Dijk <v.dijk.bas@gmail.com>2019-07-30 11:22:55 +0200
committerBas van Dijk <v.dijk.bas@gmail.com>2019-07-30 11:27:35 +0200
commit89865144c3ba0162cd37bcbe49b3095e9bab4164 (patch)
tree1a43e2906116d5ea3bcc0a39b5cd14673c191407 /src/libexpr
parent41a52466854ab3a7d4adedc3777c0b0585ef79fe (diff)
Allow builtins.pathExists to check the existence of /nix/store paths
This makes it consitent with builtins.readDir.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 070e72f3a..350dba474 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -832,8 +832,14 @@ static void prim_pathExists(EvalState & state, const Pos & pos, Value * * args,
{
PathSet context;
Path path = state.coerceToPath(pos, *args[0], context);
- if (!context.empty())
- throw EvalError(format("string '%1%' cannot refer to other paths, at %2%") % path % pos);
+ try {
+ state.realiseContext(context);
+ } catch (InvalidPathError & e) {
+ throw EvalError(format(
+ "cannot check the existence of '%1%', since path '%2%' is not valid, at %3%")
+ % path % e.path % pos);
+ }
+
try {
mkBool(v, pathExists(state.checkSourcePath(path)));
} catch (SysError & e) {