commit
0a9acefeb5
|
@ -83,15 +83,13 @@ static void prim_getContext(EvalState & state, const PosIdx pos, Value * * args,
|
||||||
state.forceString(*args[0], context, pos, "while evaluating the argument passed to builtins.getContext");
|
state.forceString(*args[0], context, pos, "while evaluating the argument passed to builtins.getContext");
|
||||||
auto contextInfos = std::map<StorePath, ContextInfo>();
|
auto contextInfos = std::map<StorePath, ContextInfo>();
|
||||||
for (const auto & p : context) {
|
for (const auto & p : context) {
|
||||||
Path drv;
|
|
||||||
std::string output;
|
|
||||||
NixStringContextElem ctx = NixStringContextElem::parse(*state.store, p);
|
NixStringContextElem ctx = NixStringContextElem::parse(*state.store, p);
|
||||||
std::visit(overloaded {
|
std::visit(overloaded {
|
||||||
[&](NixStringContextElem::DrvDeep & d) {
|
[&](NixStringContextElem::DrvDeep & d) {
|
||||||
contextInfos[d.drvPath].allOutputs = true;
|
contextInfos[d.drvPath].allOutputs = true;
|
||||||
},
|
},
|
||||||
[&](NixStringContextElem::Built & b) {
|
[&](NixStringContextElem::Built & b) {
|
||||||
contextInfos[b.drvPath].outputs.emplace_back(std::move(output));
|
contextInfos[b.drvPath].outputs.emplace_back(std::move(b.output));
|
||||||
},
|
},
|
||||||
[&](NixStringContextElem::Opaque & o) {
|
[&](NixStringContextElem::Opaque & o) {
|
||||||
contextInfos[o.path].path = true;
|
contextInfos[o.path].path = true;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
true
|
[ true true true true true true ]
|
||||||
|
|
|
@ -18,7 +18,24 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
||||||
|
legit-context = builtins.getContext combo-path;
|
||||||
|
|
||||||
constructed-context = builtins.getContext (builtins.appendContext "" desired-context);
|
reconstructed-path = builtins.appendContext
|
||||||
in legit-context == constructed-context
|
(builtins.unsafeDiscardStringContext combo-path)
|
||||||
|
desired-context;
|
||||||
|
|
||||||
|
# Eta rule for strings with context.
|
||||||
|
etaRule = str:
|
||||||
|
str == builtins.appendContext
|
||||||
|
(builtins.unsafeDiscardStringContext str)
|
||||||
|
(builtins.getContext str);
|
||||||
|
|
||||||
|
in [
|
||||||
|
(legit-context == desired-context)
|
||||||
|
(reconstructed-path == combo-path)
|
||||||
|
(etaRule "foo")
|
||||||
|
(etaRule drv.drvPath)
|
||||||
|
(etaRule drv.foo.outPath)
|
||||||
|
(etaRule (builtins.unsafeDiscardOutputDependency drv.drvPath))
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in a new issue