mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
fetchClosure: Factor out attribute hint
This commit is contained in:
parent
7b5ca7ebe2
commit
0f6d596df5
1 changed files with 6 additions and 5 deletions
|
@ -16,11 +16,13 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
|
|
||||||
for (auto & attr : *args[0]->attrs) {
|
for (auto & attr : *args[0]->attrs) {
|
||||||
const auto & attrName = state.symbols[attr.name];
|
const auto & attrName = state.symbols[attr.name];
|
||||||
|
auto attrHint = [&]() -> std::string {
|
||||||
|
return "while evaluating the '" + attrName + "' attribute passed to builtins.fetchClosure";
|
||||||
|
};
|
||||||
|
|
||||||
if (attrName == "fromPath") {
|
if (attrName == "fromPath") {
|
||||||
NixStringContext context;
|
NixStringContext context;
|
||||||
fromPath = state.coerceToStorePath(attr.pos, *attr.value, context,
|
fromPath = state.coerceToStorePath(attr.pos, *attr.value, context, attrHint());
|
||||||
"while evaluating the 'fromPath' attribute passed to builtins.fetchClosure");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (attrName == "toPath") {
|
else if (attrName == "toPath") {
|
||||||
|
@ -28,14 +30,13 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
toCA = true;
|
toCA = true;
|
||||||
if (attr.value->type() != nString || attr.value->string.s != std::string("")) {
|
if (attr.value->type() != nString || attr.value->string.s != std::string("")) {
|
||||||
NixStringContext context;
|
NixStringContext context;
|
||||||
toPath = state.coerceToStorePath(attr.pos, *attr.value, context,
|
toPath = state.coerceToStorePath(attr.pos, *attr.value, context, attrHint());
|
||||||
"while evaluating the 'toPath' attribute passed to builtins.fetchClosure");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (attrName == "fromStore")
|
else if (attrName == "fromStore")
|
||||||
fromStoreUrl = state.forceStringNoCtx(*attr.value, attr.pos,
|
fromStoreUrl = state.forceStringNoCtx(*attr.value, attr.pos,
|
||||||
"while evaluating the 'fromStore' attribute passed to builtins.fetchClosure");
|
attrHint());
|
||||||
|
|
||||||
else
|
else
|
||||||
throw Error({
|
throw Error({
|
||||||
|
|
Loading…
Reference in a new issue