aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-12 02:38:03 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-12 02:38:03 +0000
commit1c9bec226f9ff1a9586bfefcd0c3b66ed989b2d3 (patch)
tree40462d7c471963685fa66716bea802a69e7f616d /src/libexpr/primops.cc
parentabea26a9683d58e0bee43d9ededeb710f3617603 (diff)
Don't improperly assume path is store path
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index bd7ec628c..4367f9b22 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -102,10 +102,17 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
Path realPath = state.checkSourcePath(state.toRealPath(path, context));
- StorePath storePath = state.store->parseStorePath(path);
-
// FIXME
- if (state.store->isStorePath(path) && state.store->isValidPath(storePath) && isDerivation(path)) {
+ auto isValidDerivationInStore = [&]() -> std::optional<StorePath> {
+ if (!state.store->isStorePath(path))
+ return std::nullopt;
+ auto storePath = state.store->parseStorePath(path);
+ if (!(state.store->isValidPath(storePath) && isDerivation(path)))
+ return std::nullopt;
+ return storePath;
+ };
+ if (auto optStorePath = isValidDerivationInStore()) {
+ auto storePath = *optStorePath;
Derivation drv = readDerivation(*state.store, realPath, std::string(storePath.name()));
Value & w = *state.allocValue();
state.mkAttrs(w, 3 + drv.outputs.size());