mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
Move App
This commit is contained in:
parent
adf2fbbdc2
commit
bc03c6f23d
2 changed files with 28 additions and 21 deletions
28
src/nix/app.cc
Normal file
28
src/nix/app.cc
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -241,27 +241,6 @@ Buildable Installable::toBuildable()
|
||||||
return std::move(buildables[0]);
|
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>>
|
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||||
Installable::getCursors(EvalState & state, bool useEvalCache)
|
Installable::getCursors(EvalState & state, bool useEvalCache)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue