diff options
-rw-r--r-- | src/nix/app.cc | 28 | ||||
-rw-r--r-- | src/nix/installables.cc | 21 |
2 files changed, 28 insertions, 21 deletions
diff --git a/src/nix/app.cc b/src/nix/app.cc new file mode 100644 index 000000000..749dea02b --- /dev/null +++ b/src/nix/app.cc @@ -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); +} + +} diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 01be68cdb..fb79fad5d 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -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) { |