From 0b2de9d40cb35819c0977d307c3c22da925cd709 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 18 Jul 2026 10:07:41 -0400 Subject: [PATCH] Support progress for VerifyPaths. --- .gitignore | 2 + src/nix_util/activity.rs | 68 ++++++++++++++++++++++++++-- src/nix_util/activity_tree_stream.rs | 4 ++ 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1c89574..6dfed63 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /example_logs TODO.org /result +/.envrc +/.direnv/ diff --git a/src/nix_util/activity.rs b/src/nix_util/activity.rs index f7b6857..06e9ff5 100644 --- a/src/nix_util/activity.rs +++ b/src/nix_util/activity.rs @@ -215,7 +215,15 @@ impl Activity { .as_ref() .map(|phase| Cow::Owned(format!("[{}]", phase))), Activity::OptimizeStore(_activity_optimize_store) => None, - Activity::VerifyPaths(_activity_verify_paths) => None, + Activity::VerifyPaths(activity_verify_paths) => { + get_progress_bar(activity_verify_paths.done, activity_verify_paths.expected) + .or_else(|| { + get_progress_text( + activity_verify_paths.done, + activity_verify_paths.expected, + ) + }) + } Activity::Substitute(_activity_substitute) => None, Activity::QueryPathInfo(_activity_query_path_info) => None, Activity::PostBuildHook(_activity_post_build_hook) => None, @@ -323,8 +331,11 @@ impl 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::VerifyPaths(activity_verify_paths) => { + activity_verify_paths.done = done; + activity_verify_paths.expected = expected; + activity_verify_paths.running = running; + activity_verify_paths.failed = failed; } Activity::Substitute(_activity_substitute) => { panic!("Attempted to set the progress of a substitute activity."); @@ -451,6 +462,10 @@ pub(crate) struct ActivityOptimizeStore { } pub(crate) struct ActivityVerifyPaths { pub(crate) state: ActivityState, + pub(crate) done: u64, + pub(crate) expected: u64, + pub(crate) running: u64, + pub(crate) failed: u64, } pub(crate) struct ActivitySubstitute { pub(crate) state: ActivityState, @@ -493,6 +508,23 @@ impl Default for ActivityState { } fn get_progress_bar(done: u64, expected: u64) -> Option> { + if expected == 0 { + return None; + } + // ○◔◑◕● + // ○◎◉● + // ▁▂▃▄▅▆▇█ + // ▏▎▍▌▋▊▉█ + // ░▒▓█ + // + // 🮷 download + // 🮸 upload + // 🮵 + // 🮶 + get_progress_bar_clockwise_circle(done, expected) +} + +fn get_progress_bar_fade_in(done: u64, expected: u64) -> Option> { if expected == 0 { return None; } @@ -520,6 +552,36 @@ fn get_progress_bar(done: u64, expected: u64) -> Option> { } } +fn get_progress_bar_clockwise_circle(done: u64, expected: u64) -> Option> { + if expected == 0 { + return None; + } + let percent = done as f32 / expected as f32; + // ○◔◑◕● + // ○◎◉● + // ▁▂▃▄▅▆▇█ + // ▏▎▍▌▋▊▉█ + // ░▒▓█ + // + // 🮷 download + // 🮸 upload + // 🮵 + // 🮶 + if percent < 0.25 { + Some(Cow::Borrowed("○")) + } else if percent < 0.5 { + Some(Cow::Borrowed("◔")) + } else if percent < 0.75 { + Some(Cow::Borrowed("◑")) + } else if percent < 1.0 { + Some(Cow::Borrowed("◕")) + } else if percent >= 1.0 { + Some(Cow::Borrowed("●")) + } else { + None + } +} + fn get_progress_text(done: u64, expected: u64) -> Option> { Some(Cow::Owned(format!("[{}/{}]", done, expected))) } diff --git a/src/nix_util/activity_tree_stream.rs b/src/nix_util/activity_tree_stream.rs index a4f27df..4ed8880 100644 --- a/src/nix_util/activity_tree_stream.rs +++ b/src/nix_util/activity_tree_stream.rs @@ -163,6 +163,10 @@ impl ActivityTreeStream { activity_start_verify_paths.parent, Activity::VerifyPaths(ActivityVerifyPaths { state: ActivityState::default(), + done: 0, + expected: 0, + running: 0, + failed: 0, }), )?; }