mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
* 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
1 changed files with 14 additions and 13 deletions
|
@ -13,6 +13,16 @@
|
|||
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)
|
||||
{
|
||||
/* Return an attribute set containing all primops. This allows
|
||||
|
@ -43,8 +53,9 @@ static Expr primImport(EvalState & state, const ATermVector & args)
|
|||
{
|
||||
ATermList es;
|
||||
Path path;
|
||||
|
||||
Expr arg = evalExpr(state, args[0]), arg2;
|
||||
ATermList context; /* don't care the context */
|
||||
|
||||
Expr arg = unwrapContext(state, args[0], context), arg2;
|
||||
|
||||
if (matchPath(arg, 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);
|
||||
}
|
||||
|
@ -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
|
||||
as an input by derivations. */
|
||||
static Expr primToFile(EvalState & state, const ATermVector & args)
|
||||
|
|
Loading…
Reference in a new issue