aboutsummaryrefslogtreecommitdiff
path: root/src/nix/app.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-06-29 14:14:23 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-06-29 14:14:23 +0200
commitbc03c6f23dbb2d5491410075f805946d4cc62ca2 (patch)
tree7323c30c66564a8264c9585716976697891b65ba /src/nix/app.cc
parentadf2fbbdc2c94644b0d1023d844c7dc0e485a20f (diff)
Move App
Diffstat (limited to 'src/nix/app.cc')
-rw-r--r--src/nix/app.cc28
1 files changed, 28 insertions, 0 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);
+}
+
+}