diff --git a/tvix/castore/src/composition.rs b/tvix/castore/src/composition.rs index 88cedcb83..cd4064af9 100644 --- a/tvix/castore/src/composition.rs +++ b/tvix/castore/src/composition.rs @@ -218,10 +218,17 @@ pub fn add_default_services(reg: &mut Registry) { pub struct CompositionContext<'a, T: ?Sized> { stack: Vec, - composition: &'a Composition, + composition: Option<&'a Composition>, } impl<'a, T: ?Sized + Send + Sync + 'static> CompositionContext<'a, T> { + pub fn blank() -> Self { + Self { + stack: Default::default(), + composition: None, + } + } + pub async fn resolve( &self, entrypoint: String, @@ -230,10 +237,10 @@ impl<'a, T: ?Sized + Send + Sync + 'static> CompositionContext<'a, T> { if self.stack.contains(&entrypoint) { return Err(CompositionError::Recursion(self.stack.clone()).into()); } - Ok(self - .composition - .build_internal(self.stack.clone(), entrypoint) - .await?) + match self.composition { + Some(comp) => Ok(comp.build_internal(self.stack.clone(), entrypoint).await?), + None => Err(CompositionError::NotFound(entrypoint).into()), + } } } @@ -340,7 +347,7 @@ impl Composition { (async move { let mut new_context = CompositionContext { stack: stack.clone(), - composition: self, + composition: Some(self), }; new_context.stack.push(entrypoint.clone()); let res = config