diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-02-05 09:59:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 09:59:47 +0100 |
commit | a487d421019bc16d83dad66b805b550cb6b70272 (patch) | |
tree | 65319e694b50f70ea08a8cceddc7f51c717a0f48 /src | |
parent | c8937ba9f34174a0ddeb1137b523e31c4acfb6af (diff) | |
parent | e38cd5becbbff57951b6a576dd793f4777a9833c (diff) |
Merge pull request #4517 from matthewbauer/recurse-first-level-nix-search
Always enter first level of attrset in nix search
Diffstat (limited to 'src')
-rw-r--r-- | src/nix/search.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc index 9f864b3a4..c52a48d4e 100644 --- a/src/nix/search.cc +++ b/src/nix/search.cc @@ -81,9 +81,9 @@ struct CmdSearch : InstallableCommand, MixJSON uint64_t results = 0; - std::function<void(eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath)> visit; + std::function<void(eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath, bool initialRecurse)> visit; - visit = [&](eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath) + visit = [&](eval_cache::AttrCursor & cursor, const std::vector<Symbol> & attrPath, bool initialRecurse) { Activity act(*logger, lvlInfo, actUnknown, fmt("evaluating '%s'", concatStringsSep(".", attrPath))); @@ -94,7 +94,7 @@ struct CmdSearch : InstallableCommand, MixJSON auto cursor2 = cursor.getAttr(attr); auto attrPath2(attrPath); attrPath2.push_back(attr); - visit(*cursor2, attrPath2); + visit(*cursor2, attrPath2, false); } }; @@ -150,6 +150,9 @@ struct CmdSearch : InstallableCommand, MixJSON || (attrPath[0] == "packages" && attrPath.size() <= 2)) recurse(); + else if (initialRecurse) + recurse(); + else if (attrPath[0] == "legacyPackages" && attrPath.size() > 2) { auto attr = cursor.maybeGetAttr(state->sRecurseForDerivations); if (attr && attr->getBool()) @@ -163,7 +166,7 @@ struct CmdSearch : InstallableCommand, MixJSON }; for (auto & [cursor, prefix] : installable->getCursors(*state)) - visit(*cursor, parseAttrPath(*state, prefix)); + visit(*cursor, parseAttrPath(*state, prefix), true); if (!json && !results) throw Error("no results for the given search term(s)!"); |