forked from lix-project/lix
Merge pull request #3012 from basvandijk/fix-pathExists
Allow builtins.pathExists to check the existence of /nix/store paths
This commit is contained in:
commit
7680357ccc
|
@ -832,8 +832,14 @@ static void prim_pathExists(EvalState & state, const Pos & pos, Value * * args,
|
||||||
{
|
{
|
||||||
PathSet context;
|
PathSet context;
|
||||||
Path path = state.coerceToPath(pos, *args[0], context);
|
Path path = state.coerceToPath(pos, *args[0], context);
|
||||||
if (!context.empty())
|
try {
|
||||||
throw EvalError(format("string '%1%' cannot refer to other paths, at %2%") % path % pos);
|
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 {
|
try {
|
||||||
mkBool(v, pathExists(state.checkSourcePath(path)));
|
mkBool(v, pathExists(state.checkSourcePath(path)));
|
||||||
} catch (SysError & e) {
|
} catch (SysError & e) {
|
||||||
|
|
|
@ -10,7 +10,10 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
value = import bar;
|
value =
|
||||||
|
# Test that pathExists can check the existence of /nix/store paths
|
||||||
|
assert builtins.pathExists bar;
|
||||||
|
import bar;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue