forked from lix-project/lix
* import': unwrap the context. Necessary to make
import (x + y)'
work, where x is a store path.
This commit is contained in:
parent
7bada48b36
commit
bd0c40e1e9
|
@ -13,6 +13,16 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
|
static Expr unwrapContext(EvalState & state, Expr e, ATermList & context)
|
||||||
|
{
|
||||||
|
context = ATempty;
|
||||||
|
e = evalExpr(state, e);
|
||||||
|
if (matchContext(e, context, e))
|
||||||
|
e = evalExpr(state, e);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Expr primBuiltins(EvalState & state, const ATermVector & args)
|
static Expr primBuiltins(EvalState & state, const ATermVector & args)
|
||||||
{
|
{
|
||||||
/* Return an attribute set containing all primops. This allows
|
/* Return an attribute set containing all primops. This allows
|
||||||
|
@ -43,8 +53,9 @@ static Expr primImport(EvalState & state, const ATermVector & args)
|
||||||
{
|
{
|
||||||
ATermList es;
|
ATermList es;
|
||||||
Path path;
|
Path path;
|
||||||
|
ATermList context; /* don't care the context */
|
||||||
Expr arg = evalExpr(state, args[0]), arg2;
|
|
||||||
|
Expr arg = unwrapContext(state, args[0], context), arg2;
|
||||||
|
|
||||||
if (matchPath(arg, arg2))
|
if (matchPath(arg, arg2))
|
||||||
path = aterm2String(arg2);
|
path = aterm2String(arg2);
|
||||||
|
@ -67,7 +78,7 @@ static Expr primImport(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else throw TypeError("`import' requires a path or derivation as its argument");
|
else throw TypeError(format("argument of `import' is %1% while a path or derivation is required") % showType(arg));
|
||||||
|
|
||||||
return evalFile(state, path);
|
return evalFile(state, path);
|
||||||
}
|
}
|
||||||
|
@ -513,16 +524,6 @@ static Expr primToXML(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Expr unwrapContext(EvalState & state, Expr e, ATermList & context)
|
|
||||||
{
|
|
||||||
context = ATempty;
|
|
||||||
e = evalExpr(state, e);
|
|
||||||
if (matchContext(e, context, e))
|
|
||||||
e = evalExpr(state, e);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Store a string in the Nix store as a source file that can be used
|
/* Store a string in the Nix store as a source file that can be used
|
||||||
as an input by derivations. */
|
as an input by derivations. */
|
||||||
static Expr primToFile(EvalState & state, const ATermVector & args)
|
static Expr primToFile(EvalState & state, const ATermVector & args)
|
||||||
|
|
Loading…
Reference in a new issue