This commit is contained in:
Eelco Dolstra 2020-06-29 14:14:23 +02:00
parent adf2fbbdc2
commit bc03c6f23d
2 changed files with 28 additions and 21 deletions

28
src/nix/app.cc Normal file
View file

@ -0,0 +1,28 @@
#include "installables.hh"
#include "store-api.hh"
#include "eval-inline.hh"
namespace nix {
App::App(EvalState & state, Value & vApp)
{
state.forceAttrs(vApp);
auto aType = vApp.attrs->need(state.sType);
if (state.forceStringNoCtx(*aType.value, *aType.pos) != "app")
throw Error("value does not have type 'app', at %s", *aType.pos);
auto aProgram = vApp.attrs->need(state.symbols.create("program"));
program = state.forceString(*aProgram.value, context, *aProgram.pos);
// FIXME: check that 'program' is in the closure of 'context'.
if (!state.store->isInStore(program))
throw Error("app program '%s' is not in the Nix store", program);
}
App Installable::toApp(EvalState & state)
{
return App(state, *toValue(state).first);
}
}

View file

@ -241,27 +241,6 @@ Buildable Installable::toBuildable()
return std::move(buildables[0]);
}
App::App(EvalState & state, Value & vApp)
{
state.forceAttrs(vApp);
auto aType = vApp.attrs->need(state.sType);
if (state.forceStringNoCtx(*aType.value, *aType.pos) != "app")
throw Error("value does not have type 'app', at %s", *aType.pos);
auto aProgram = vApp.attrs->need(state.symbols.create("program"));
program = state.forceString(*aProgram.value, context, *aProgram.pos);
// FIXME: check that 'program' is in the closure of 'context'.
if (!state.store->isInStore(program))
throw Error("app program '%s' is not in the Nix store", program);
}
App Installable::toApp(EvalState & state)
{
return App(state, *toValue(state).first);
}
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
Installable::getCursors(EvalState & state, bool useEvalCache)
{