about summary refs log tree commit diff
path: root/src/nix/installables.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-07-19T14·06+0200
committerEelco Dolstra <edolstra@gmail.com>2017-07-20T11·33+0200
commit57a30e101b36a064f09619bf4a3f0b8a3fdcdcad (patch)
treea9be7e2f1fc773ee7944d58be9b6593e26a10e88 /src/nix/installables.cc
parentfc3568e2633bf3faa234509cfc6034be95f10b6e (diff)
nix search: Ignore top-level eval errors
$NIX_PATH may contain elements that don't evaluate to an attrset (like
"nixos-config"), so ignore those.
Diffstat (limited to 'src/nix/installables.cc')
-rw-r--r--src/nix/installables.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index 4da736f4d5c3..59162fdc1163 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -16,6 +16,8 @@ Value * SourceExprCommand::getSourceExpr(EvalState & state)
 {
     if (vSourceExpr) return vSourceExpr;
 
+    auto sToplevel = state.symbols.create("_toplevel");
+
     vSourceExpr = state.allocValue();
 
     if (file != "") {
@@ -29,7 +31,9 @@ Value * SourceExprCommand::getSourceExpr(EvalState & state)
 
         auto searchPath = state.getSearchPath();
 
-        state.mkAttrs(*vSourceExpr, searchPath.size());
+        state.mkAttrs(*vSourceExpr, searchPath.size() + 1);
+
+        mkBool(*state.allocAttr(*vSourceExpr, sToplevel), true);
 
         std::unordered_set<std::string> seen;