From bc03c6f23dbb2d5491410075f805946d4cc62ca2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 29 Jun 2020 14:14:23 +0200 Subject: [PATCH] Move App --- src/nix/app.cc | 28 ++++++++++++++++++++++++++++ src/nix/installables.cc | 21 --------------------- 2 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 src/nix/app.cc 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::string>> Installable::getCursors(EvalState & state, bool useEvalCache) {