See cyclic dependencies need grouping · Issue #198 · nix-community/dream2nix · GitHub
- given a package
pkg
and a set ofseen = {dep = true}
and a list ofcycles = [ [dep...]... ]
:- for each dependency, check if it is in
seen
- if so:
- if dep is already in a cycle, add
pkg
to it (*) - if not, create a new cycle
[dep, pkg]
(*) - (*) note that due to siblings, pkg could already be in a cycle. In this case, the cycles have to be merged, not just the pkg.
- (so this stops recursion)
- if dep is already in a cycle, add
- if not: call this search with pkg=dep, and pass
seen = seen // {pkg=true}
; thecycles
need to be shared between the recursive calls
- if so:
- for each dependency, check if it is in
Call the algorithm on pkg with seen = {}
.
So, passing a seen
attribute that is recursively augmented is easy, but how to express that cycles
object that should grow as the dependency tree is traversed?