Fix derivation primop
This commit is contained in:
parent
cbfbf71e08
commit
acd6bddec7
3 changed files with 20 additions and 9 deletions
|
@ -583,14 +583,20 @@ Value * EvalState::addConstant(const string & name, Value & v)
|
||||||
{
|
{
|
||||||
Value * v2 = allocValue();
|
Value * v2 = allocValue();
|
||||||
*v2 = v;
|
*v2 = v;
|
||||||
staticBaseEnv.vars.emplace_back(symbols.create(name), baseEnvDispl);
|
addConstant(name, v2);
|
||||||
baseEnv.values[baseEnvDispl++] = v2;
|
|
||||||
string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name;
|
|
||||||
baseEnv.values[0]->attrs->push_back(Attr(symbols.create(name2), v2));
|
|
||||||
return v2;
|
return v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalState::addConstant(const string & name, Value * v)
|
||||||
|
{
|
||||||
|
staticBaseEnv.vars.emplace_back(symbols.create(name), baseEnvDispl);
|
||||||
|
baseEnv.values[baseEnvDispl++] = v;
|
||||||
|
string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name;
|
||||||
|
baseEnv.values[0]->attrs->push_back(Attr(symbols.create(name2), v));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Value * EvalState::addPrimOp(const string & name,
|
Value * EvalState::addPrimOp(const string & name,
|
||||||
size_t arity, PrimOpFun primOp)
|
size_t arity, PrimOpFun primOp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -277,6 +277,8 @@ private:
|
||||||
|
|
||||||
Value * addConstant(const string & name, Value & v);
|
Value * addConstant(const string & name, Value & v);
|
||||||
|
|
||||||
|
void addConstant(const string & name, Value * v);
|
||||||
|
|
||||||
constexpr static size_t maxPrimOpArity = 3;
|
constexpr static size_t maxPrimOpArity = 3;
|
||||||
|
|
||||||
Value * addPrimOp(const string & name,
|
Value * addPrimOp(const string & name,
|
||||||
|
|
|
@ -3725,18 +3725,21 @@ void EvalState::createBaseEnv()
|
||||||
|
|
||||||
/* Add a wrapper around the derivation primop that computes the
|
/* Add a wrapper around the derivation primop that computes the
|
||||||
`drvPath' and `outPath' attributes lazily. */
|
`drvPath' and `outPath' attributes lazily. */
|
||||||
staticBaseEnv.sort();
|
|
||||||
sDerivationNix = symbols.create("//builtin/derivation.nix");
|
sDerivationNix = symbols.create("//builtin/derivation.nix");
|
||||||
eval(parse(
|
auto vDerivation = allocValue();
|
||||||
#include "primops/derivation.nix.gen.hh"
|
addConstant("derivation", vDerivation);
|
||||||
, foFile, sDerivationNix, "/", staticBaseEnv), v);
|
|
||||||
addConstant("derivation", v);
|
|
||||||
|
|
||||||
/* Now that we've added all primops, sort the `builtins' set,
|
/* Now that we've added all primops, sort the `builtins' set,
|
||||||
because attribute lookups expect it to be sorted. */
|
because attribute lookups expect it to be sorted. */
|
||||||
baseEnv.values[0]->attrs->sort();
|
baseEnv.values[0]->attrs->sort();
|
||||||
|
|
||||||
staticBaseEnv.sort();
|
staticBaseEnv.sort();
|
||||||
|
|
||||||
|
/* Note: we have to initialize the 'derivation' constant *after*
|
||||||
|
building baseEnv/staticBaseEnv because it uses 'builtins'. */
|
||||||
|
eval(parse(
|
||||||
|
#include "primops/derivation.nix.gen.hh"
|
||||||
|
, foFile, sDerivationNix, "/", staticBaseEnv), *vDerivation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue