pub struct FollowsGraph { /* private fields */ }Expand description
Index of follows Edges keyed by their source path. Construct with
Self::from_declared, Self::from_lock, or Self::from_flake for
declared-only, resolved-only, or merged views respectively.
Implementations§
Source§impl FollowsGraph
impl FollowsGraph
Sourcepub fn from_declared(inputs: &InputMap) -> Self
pub fn from_declared(inputs: &InputMap) -> Self
Build a graph from the declared inputs = { ... } block alone.
Each Follows::Indirect in inputs becomes one
EdgeOrigin::Declared edge carrying Input::range.
Sourcepub fn from_lock(lock: &FlakeLock) -> Self
pub fn from_lock(lock: &FlakeLock) -> Self
Build a graph from the lockfile alone.
Walks flake.lock from the root once via FlakeLock::nested_inputs
and defers to Self::from_nested_inputs.
Sourcepub fn from_nested_inputs(nested_inputs: &[NestedInput]) -> Self
pub fn from_nested_inputs(nested_inputs: &[NestedInput]) -> Self
Build the lock graph from an already-computed nested-input set.
Emits one EdgeOrigin::Resolved edge per inputs.X = ["a", "b", ...]
follows override, bounded by DEFAULT_MAX_DEPTH. Every nested-input
path is recorded in resolved_universe, with or without a follows.
Takes the precomputed slice so a single FlakeLock::nested_inputs
walk can feed every consumer in one invocation.
Sourcepub fn from_flake(inputs: &InputMap, lock: &FlakeLock) -> Self
pub fn from_flake(inputs: &InputMap, lock: &FlakeLock) -> Self
Build the merged graph: declared edges first, then resolved edges
from the lockfile that no existing edge already covers at the same
(source, follows). Every nested-input path observed in the
lockfile is recorded in resolved_universe.
Dedup is by (source, follows), not by source alone: a declared
edge and its resolved sibling can share a source but point at
different targets (the user’s depth-N follow points at the user’s
top-level input; the lockfile points at the upstream’s intermediate
path). Both encode distinct reachability and
Self::lock_routes_to needs the resolved sibling to survive when
the declared edge is excluded as a candidate.
Sourcepub fn with_max_depth(self, max: usize) -> Self
pub fn with_max_depth(self, max: usize) -> Self
Override the traversal depth bound. Default is DEFAULT_MAX_DEPTH.
Sourcepub fn edges(&self) -> impl Iterator<Item = &Edge>
pub fn edges(&self) -> impl Iterator<Item = &Edge>
Iterator over every edge.
Order is unspecified (HashMap-derived). Callers that need a deterministic order must sort after collecting.
Sourcepub fn declared_edges(&self) -> impl Iterator<Item = &Edge>
pub fn declared_edges(&self) -> impl Iterator<Item = &Edge>
Edges originating from flake.nix. See Self::edges on ordering.
Sourcepub fn declared_sources(&self) -> HashSet<AttrPath>
pub fn declared_sources(&self) -> HashSet<AttrPath>
Every source path the user has declared a follows for in
flake.nix, regardless of whether it resolves to a target. The
union of Self::declared_edges sources and the nulled
(follows = "") sources tracked alongside them.
Distinct from Self::declared_edges because the auto-follow
pipeline must treat a nulled declaration as “already user-owned”
and skip it; the edges-only view drops nulled sources because
they have no target to put on the right-hand side of an edge.
Sourcepub fn declared_nulled(&self) -> &HashSet<AttrPath>
pub fn declared_nulled(&self) -> &HashSet<AttrPath>
Read-only view of source paths declared as follows = "". The
auto-deduplicator consults this to distinguish a nulled
declaration (user explicitly opted out) from a path with a real
follows target.
Sourcepub fn cycles(&self) -> Vec<Cycle>
pub fn cycles(&self) -> Vec<Cycle>
Cycles among declared edges only: detects per-segment self-cycles
where an edge’s source equals its follows. Multi-hop and lockfile-only
cycle detection lives on Self::would_create_cycle.
Sourcepub fn stale_edges(&self) -> Vec<&Edge>
pub fn stale_edges(&self) -> Vec<&Edge>
Declared edges whose source path no longer appears in the lockfile.
A follows declaration whose nested input is gone from flake.lock
should be dropped on the next auto-follow pass. Lex-sorted by source.
Sourcepub fn stale_nulled_sources(&self) -> Vec<&AttrPath>
pub fn stale_nulled_sources(&self) -> Vec<&AttrPath>
Sibling of Self::stale_edges for Self::declared_nulled:
nulled (follows = "") declarations whose source is absent from
resolved_universe. A nulled declaration backed by an
inputs.X = [] lock entry stays in resolved_universe and is not
reported. Lex-sorted.
Sourcepub fn stale_lock_declarations<'a>(
&'a self,
nested_inputs: &[NestedInput],
) -> Vec<StaleLockDeclaration<'a>>
pub fn stale_lock_declarations<'a>( &'a self, nested_inputs: &[NestedInput], ) -> Vec<StaleLockDeclaration<'a>>
Declared follows whose target disagrees with the lockfile’s resolution for the same source path.
A returned entry means flake.nix declares a follows for
entry.declared.source pointing at entry.declared.follows, but the
lock has either:
lock_target = Some(other): a different resolved target, orlock_target = None: no follows at all (override never applied).
Both cases call for nix flake lock. Sources missing from the
lockfile entirely are reported by Self::stale_edges instead.
Lex-sorted by source.
Sourcepub fn would_create_cycle(&self, proposed: &Edge) -> bool
pub fn would_create_cycle(&self, proposed: &Edge) -> bool
Whether adding proposed would close a follows cycle.
Origin-agnostic DFS from proposed.follows. Reaching proposed.source
means the new edge closes a cycle. Beyond the trivial self-edge case,
three classes are covered:
- Dot-named ancestor.
AttrPathequality is structural, so a participant like"hls-1.10"compares by its unquoted segment value, not by URL prefix. - Multi-hop chains. A cycle
A → B → C → ... → Ais found by walking the chain. - Lockfile-only cycles.
EdgeOrigin::Resolvededges are traversed alongside declared ones, so a chain closing only through the lockfile is still reported.
Bounded by Self::with_max_depth for malformed graphs. Standard
visited / on-stack sets keep pre-existing cycles from wedging the walk.
Sourcepub fn drop_edges_with_sources(&mut self, sources: &[AttrPath])
pub fn drop_edges_with_sources(&mut self, sources: &[AttrPath])
Drop every edge whose source is in sources.
Hides a known set of edges from Self::would_create_cycle and
Self::lock_routes_to without re-deriving the graph from
scratch. resolved_universe is intentionally untouched: removing
a declared edge does not retroactively unobserve the lockfile
path the source was discovered from.
Sourcepub fn lock_routes_to(
&self,
source: &AttrPath,
target: &AttrPath,
exclude: Option<&Edge>,
extra_edges: &[(AttrPath, AttrPath)],
) -> bool
pub fn lock_routes_to( &self, source: &AttrPath, target: &AttrPath, exclude: Option<&Edge>, extra_edges: &[(AttrPath, AttrPath)], ) -> bool
Whether the graph routes source transitively to target, ignoring
exclude if given. extra_edges are treated as additional
declared-style edges for callers staging follows not yet in the graph.
Walks both EdgeOrigin::Declared and EdgeOrigin::Resolved edges:
Self::from_flake keeps only one when both encode the same
(source, target), so restricting the walk to one variant would miss
chains closing through the deduped edge.
Trait Implementations§
Source§impl Clone for FollowsGraph
impl Clone for FollowsGraph
Source§fn clone(&self) -> FollowsGraph
fn clone(&self) -> FollowsGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FollowsGraph
impl Debug for FollowsGraph
Auto Trait Implementations§
impl Freeze for FollowsGraph
impl RefUnwindSafe for FollowsGraph
impl Send for FollowsGraph
impl Sync for FollowsGraph
impl Unpin for FollowsGraph
impl UnsafeUnpin for FollowsGraph
impl UnwindSafe for FollowsGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more