mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
handle circular flake dependencies in list-inputs
This commit is contained in:
parent
5f64655ff4
commit
8d67794da1
1 changed files with 9 additions and 3 deletions
|
@ -158,20 +158,26 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
|
||||||
else {
|
else {
|
||||||
logger->stdout("%s", flake.flake.lockedRef);
|
logger->stdout("%s", flake.flake.lockedRef);
|
||||||
|
|
||||||
|
std::unordered_set<std::shared_ptr<Node>> visited;
|
||||||
|
|
||||||
std::function<void(const Node & node, const std::string & prefix)> recurse;
|
std::function<void(const Node & node, const std::string & prefix)> recurse;
|
||||||
|
|
||||||
recurse = [&](const Node & node, const std::string & prefix)
|
recurse = [&](const Node & node, const std::string & prefix)
|
||||||
{
|
{
|
||||||
for (const auto & [i, input] : enumerate(node.inputs)) {
|
for (const auto & [i, input] : enumerate(node.inputs)) {
|
||||||
//auto tree2 = tree.child(i + 1 == inputs.inputs.size());
|
bool firstVisit = visited.insert(input.second).second;
|
||||||
bool last = i + 1 == node.inputs.size();
|
bool last = i + 1 == node.inputs.size();
|
||||||
|
auto lockedNode = std::dynamic_pointer_cast<const LockedNode>(input.second);
|
||||||
|
|
||||||
logger->stdout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
|
logger->stdout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
|
||||||
prefix + (last ? treeLast : treeConn), input.first,
|
prefix + (last ? treeLast : treeConn), input.first,
|
||||||
std::dynamic_pointer_cast<const LockedNode>(input.second)->lockedRef);
|
lockedNode ? lockedNode->lockedRef : flake.flake.lockedRef);
|
||||||
recurse(*input.second, prefix + (last ? treeNull : treeLine));
|
|
||||||
|
if (firstVisit) recurse(*input.second, prefix + (last ? treeNull : treeLine));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
visited.insert(flake.lockFile.root);
|
||||||
recurse(*flake.lockFile.root, "");
|
recurse(*flake.lockFile.root, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue