Process results from the nix output stream.

This commit is contained in:
Tom Alexander
2026-02-28 14:53:43 -05:00
parent 2b7349a7ae
commit 4fdff95039
3 changed files with 241 additions and 47 deletions

View File

@@ -201,6 +201,179 @@ impl Activity {
Activity::FetchTree(_activity_fetch_tree) => Some(Cow::Borrowed("FetchTree")),
}
}
pub(crate) fn set_phase(&mut self, phase: Option<String>) -> () {
match self {
Activity::Root(_activity_root) => {
panic!("Attempted to set the phase of a root activity.");
}
Activity::Unknown(_activity_unknown) => {
panic!("Attempted to set the phase of an unknown activity.");
}
Activity::CopyPath(_activity_copy_path) => {
panic!("Attempted to set the phase of a copy path activity.");
}
Activity::FileTransfer(_activity_file_transfer) => {
panic!("Attempted to set the phase of a file transfer activity.");
}
Activity::Realize(_activity_realize) => {
panic!("Attempted to set the phase of a realize activity.");
}
Activity::CopyPaths(_activity_copy_paths) => {
panic!("Attempted to set the phase of a copy paths activity.");
}
Activity::Builds(_activity_builds) => {
panic!("Attempted to set the phase of a builds activity.");
}
Activity::Build(activity_build) => {
activity_build.phase = phase;
}
Activity::OptimizeStore(_activity_optimize_store) => {
panic!("Attempted to set the phase of an optimize store activity.");
}
Activity::VerifyPaths(_activity_verify_paths) => {
panic!("Attempted to set the phase of a verify paths activity.");
}
Activity::Substitute(_activity_substitute) => {
panic!("Attempted to set the phase of a substitute activity.");
}
Activity::QueryPathInfo(_activity_query_path_info) => {
panic!("Attempted to set the phase of a query path info activity.");
}
Activity::PostBuildHook(_activity_post_build_hook) => {
panic!("Attempted to set the phase of a post build hook activity.");
}
Activity::BuildWaiting(_activity_build_waiting) => {
panic!("Attempted to set the phase of a build waiting activity.");
}
Activity::FetchTree(_activity_fetch_tree) => {
panic!("Attempted to set the phase of a fetch tree activity.");
}
}
}
pub(crate) fn set_progress(
&mut self,
done: u64,
expected: u64,
running: u64,
failed: u64,
) -> () {
match self {
Activity::Root(_activity_root) => {
panic!("Attempted to set the progress of a root activity.");
}
Activity::Unknown(_activity_unknown) => {
panic!("Attempted to set the progress of an unknown activity.");
}
Activity::CopyPath(activity_copy_path) => {
if running != 0 || failed != 0 {
panic!("Attempted to set the progress of a copy path activity.");
}
activity_copy_path.done = done;
activity_copy_path.expected = expected;
}
Activity::FileTransfer(activity_file_transfer) => {
if running != 0 || failed != 0 {
panic!("Attempted to set the progress of a file transfer activity.");
}
activity_file_transfer.done = done;
activity_file_transfer.expected = expected;
}
Activity::Realize(_activity_realize) => {
panic!("Attempted to set the progress of a realize activity.");
}
Activity::CopyPaths(activity_copy_paths) => {
activity_copy_paths.done = done;
activity_copy_paths.expected = expected;
activity_copy_paths.running = running;
activity_copy_paths.failed = failed;
}
Activity::Builds(activity_builds) => {
activity_builds.done = done;
activity_builds.expected = expected;
activity_builds.running = running;
activity_builds.failed = failed;
}
Activity::Build(_activity_build) => {
panic!("Attempted to set the progress of a build activity.");
}
Activity::OptimizeStore(_activity_optimize_store) => {
panic!("Attempted to set the progress of an optimize store activity.");
}
Activity::VerifyPaths(_activity_verify_paths) => {
panic!("Attempted to set the progress of a verify paths activity.");
}
Activity::Substitute(_activity_substitute) => {
panic!("Attempted to set the progress of a substitute activity.");
}
Activity::QueryPathInfo(_activity_query_path_info) => {
panic!("Attempted to set the progress of a query path info activity.");
}
Activity::PostBuildHook(_activity_post_build_hook) => {
panic!("Attempted to set the progress of a post build hook activity.");
}
Activity::BuildWaiting(_activity_build_waiting) => {
panic!("Attempted to set the progress of a build waiting activity.");
}
Activity::FetchTree(_activity_fetch_tree) => {
panic!("Attempted to set the progress of a fetch tree activity.");
}
}
}
pub(crate) fn set_expected(&mut self, expected: u64) -> () {
match self {
Activity::Root(_activity_root) => {
panic!("Attempted to set the expected of a root activity.");
}
Activity::Unknown(_activity_unknown) => {
panic!("Attempted to set the expected of an unknown activity.");
}
Activity::CopyPath(_activity_copy_path) => {
panic!("Attempted to set the expected of a copy path activity.");
}
Activity::FileTransfer(_activity_file_transfer) => {
panic!("Attempted to set the expected of a file transfer activity.");
}
Activity::Realize(_activity_realize) => {
// Seems to always be zero?
if expected != 0 {
panic!("Attempted to set the expected of a realize activity.");
}
}
Activity::CopyPaths(activity_copy_paths) => {
activity_copy_paths.expected = expected;
}
Activity::Builds(_activity_builds) => {
panic!("Attempted to set the expected of a builds activity.");
}
Activity::Build(_activity_build) => {
panic!("Attempted to set the expected of a build activity.");
}
Activity::OptimizeStore(_activity_optimize_store) => {
panic!("Attempted to set the expected of an optimize store activity.");
}
Activity::VerifyPaths(_activity_verify_paths) => {
panic!("Attempted to set the expected of a verify paths activity.");
}
Activity::Substitute(_activity_substitute) => {
panic!("Attempted to set the expected of a substitute activity.");
}
Activity::QueryPathInfo(_activity_query_path_info) => {
panic!("Attempted to set the expected of a query path info activity.");
}
Activity::PostBuildHook(_activity_post_build_hook) => {
panic!("Attempted to set the expected of a post build hook activity.");
}
Activity::BuildWaiting(_activity_build_waiting) => {
panic!("Attempted to set the expected of a build waiting activity.");
}
Activity::FetchTree(_activity_fetch_tree) => {
panic!("Attempted to set the expected of a fetch tree activity.");
}
}
}
}
pub(crate) struct ActivityRoot {}
@@ -217,10 +390,15 @@ pub(crate) struct ActivityCopyPath {
/// The machine that is receiving the file(s)
pub(crate) destination: String,
pub(crate) done: u64,
pub(crate) expected: u64,
}
pub(crate) struct ActivityFileTransfer {
pub(crate) state: ActivityState,
pub(crate) url: String,
pub(crate) done: u64,
pub(crate) expected: u64,
}
pub(crate) struct ActivityRealize {
pub(crate) state: ActivityState,
@@ -228,14 +406,23 @@ pub(crate) struct ActivityRealize {
pub(crate) struct ActivityCopyPaths {
pub(crate) state: ActivityState,
pub(crate) text: String,
pub(crate) done: u64,
pub(crate) expected: u64,
pub(crate) running: u64,
pub(crate) failed: u64,
}
pub(crate) struct ActivityBuilds {
pub(crate) state: ActivityState,
pub(crate) done: u64,
pub(crate) expected: u64,
pub(crate) running: u64,
pub(crate) failed: u64,
}
pub(crate) struct ActivityBuild {
pub(crate) state: ActivityState,
pub(crate) drv_path: String,
pub(crate) machine_name: Option<String>,
pub(crate) phase: Option<String>,
}
pub(crate) struct ActivityOptimizeStore {
pub(crate) state: ActivityState,