diff --git a/rom/src/state.rs b/rom/src/state.rs index 4ae014c..cc47ee7 100644 --- a/rom/src/state.rs +++ b/rom/src/state.rs @@ -18,10 +18,6 @@ pub type DerivationId = usize; /// Unique identifier for activities pub type ActivityId = Id; - - - - /// Store path representation #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StorePath { @@ -85,9 +81,6 @@ impl Derivation { } } - - - /// Transfer information (download/upload) #[derive(Debug, Clone)] pub struct TransferInfo { @@ -324,6 +317,20 @@ pub struct ActivityStatus { pub text: String, pub parent: Option, pub phase: Option, + pub progress: Option, +} + +/// Activity progress for downloads/uploads/builds +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ActivityProgress { + /// Bytes completed + pub done: u64, + /// Total bytes expected + pub expected: u64, + /// Currently running transfers + pub running: u64, + /// Failed transfers + pub failed: u64, } /// Build report for caching @@ -361,6 +368,7 @@ pub struct State { pub activities: HashMap, pub nix_errors: Vec, pub build_logs: Vec, + pub traces: Vec, pub build_platform: Option, pub evaluation_state: EvalInfo, next_store_path_id: StorePathId, @@ -390,6 +398,7 @@ impl State { activities: HashMap::new(), nix_errors: Vec::new(), build_logs: Vec::new(), + traces: Vec::new(), build_platform: None, evaluation_state: EvalInfo::default(), next_store_path_id: 0, @@ -664,6 +673,30 @@ impl State { .map(|(id, info)| (*id, info)) .collect() } + + /// Check if a derivation has a platform mismatch + #[must_use] + pub fn has_platform_mismatch(&self, id: DerivationId) -> bool { + if let (Some(build_platform), Some(info)) = + (&self.build_platform, self.get_derivation_info(id)) + { + if let Some(drv_platform) = &info.platform { + return build_platform != drv_platform; + } + } + false + } + + /// Get all derivations with platform mismatches + #[must_use] + pub fn platform_mismatches(&self) -> Vec { + self + .derivation_infos + .keys() + .filter(|&&id| self.has_platform_mismatch(id)) + .copied() + .collect() + } } #[must_use] @@ -674,8 +707,6 @@ pub fn current_time() -> f64 { .as_secs_f64() } - - #[cfg(test)] mod tests { use super::*;