fix(3p/nix): Update for usage of new attribute set API
The new attribute set API uses the iterators of the btree_map directly. This requires changes in various files because the internals of libexpr are very entangled. This code runs and compiles, but there is a bug causing empty attribute sets to be assigned incorrectly.
This commit is contained in:
parent
42205f27fc
commit
986a8f6b75
14 changed files with 187 additions and 176 deletions
51
third_party/nix/src/libexpr/primops/context.cc
vendored
51
third_party/nix/src/libexpr/primops/context.cc
vendored
|
|
@ -147,47 +147,48 @@ static void prim_appendContext(EvalState& state, const Pos& pos, Value** args,
|
|||
|
||||
auto sPath = state.symbols.Create("path");
|
||||
auto sAllOutputs = state.symbols.Create("allOutputs");
|
||||
for (auto& i : *args[1]->attrs) {
|
||||
if (!state.store->isStorePath(i.name))
|
||||
throw EvalError("Context key '%s' is not a store path, at %s", i.name,
|
||||
i.pos);
|
||||
for (const auto& attr_iter : *args[1]->attrs) {
|
||||
const Attr* i = &attr_iter.second; // TODO(tazjin): get rid of this
|
||||
if (!state.store->isStorePath(i->name))
|
||||
throw EvalError("Context key '%s' is not a store path, at %s", i->name,
|
||||
i->pos);
|
||||
if (!settings.readOnlyMode) {
|
||||
state.store->ensurePath(i.name);
|
||||
state.store->ensurePath(i->name);
|
||||
}
|
||||
state.forceAttrs(*i.value, *i.pos);
|
||||
auto iter = i.value->attrs->find(sPath);
|
||||
if (iter != i.value->attrs->end()) {
|
||||
if (state.forceBool(*iter->value, *iter->pos)) {
|
||||
context.insert(i.name);
|
||||
state.forceAttrs(*i->value, *i->pos);
|
||||
auto iter = i->value->attrs->find(sPath);
|
||||
if (iter != i->value->attrs->end()) {
|
||||
if (state.forceBool(*iter->second.value, *iter->second.pos)) {
|
||||
context.insert(i->name);
|
||||
}
|
||||
}
|
||||
|
||||
iter = i.value->attrs->find(sAllOutputs);
|
||||
if (iter != i.value->attrs->end()) {
|
||||
if (state.forceBool(*iter->value, *iter->pos)) {
|
||||
if (!isDerivation(i.name)) {
|
||||
iter = i->value->attrs->find(sAllOutputs);
|
||||
if (iter != i->value->attrs->end()) {
|
||||
if (state.forceBool(*iter->second.value, *iter->second.pos)) {
|
||||
if (!isDerivation(i->name)) {
|
||||
throw EvalError(
|
||||
"Tried to add all-outputs context of %s, which is not a "
|
||||
"derivation, to a string, at %s",
|
||||
i.name, i.pos);
|
||||
i->name, i->pos);
|
||||
}
|
||||
context.insert("=" + string(i.name));
|
||||
context.insert("=" + string(i->name));
|
||||
}
|
||||
}
|
||||
|
||||
iter = i.value->attrs->find(state.sOutputs);
|
||||
if (iter != i.value->attrs->end()) {
|
||||
state.forceList(*iter->value, *iter->pos);
|
||||
if (iter->value->listSize() && !isDerivation(i.name)) {
|
||||
iter = i->value->attrs->find(state.sOutputs);
|
||||
if (iter != i->value->attrs->end()) {
|
||||
state.forceList(*iter->second.value, *iter->second.pos);
|
||||
if (iter->second.value->listSize() && !isDerivation(i->name)) {
|
||||
throw EvalError(
|
||||
"Tried to add derivation output context of %s, which is not a "
|
||||
"derivation, to a string, at %s",
|
||||
i.name, i.pos);
|
||||
i->name, i->pos);
|
||||
}
|
||||
for (unsigned int n = 0; n < iter->value->listSize(); ++n) {
|
||||
auto name =
|
||||
state.forceStringNoCtx(*iter->value->listElems()[n], *iter->pos);
|
||||
context.insert("!" + name + "!" + string(i.name));
|
||||
for (unsigned int n = 0; n < iter->second.value->listSize(); ++n) {
|
||||
auto name = state.forceStringNoCtx(*iter->second.value->listElems()[n],
|
||||
*iter->second.pos);
|
||||
context.insert("!" + name + "!" + string(i->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,8 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args,
|
|||
if (args[0]->type == tAttrs) {
|
||||
state.forceAttrs(*args[0], pos);
|
||||
|
||||
for (auto& attr : *args[0]->attrs) {
|
||||
for (auto& attr_iter : *args[0]->attrs) {
|
||||
auto& attr = attr_iter.second;
|
||||
std::string n(attr.name);
|
||||
if (n == "url")
|
||||
url =
|
||||
|
|
|
|||
|
|
@ -190,7 +190,8 @@ static void prim_fetchMercurial(EvalState& state, const Pos& pos, Value** args,
|
|||
if (args[0]->type == tAttrs) {
|
||||
state.forceAttrs(*args[0], pos);
|
||||
|
||||
for (auto& attr : *args[0]->attrs) {
|
||||
for (auto& attr_iter : *args[0]->attrs) {
|
||||
auto& attr = attr_iter.second;
|
||||
std::string n(attr.name);
|
||||
if (n == "url")
|
||||
url =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue