diff options
| author | seth <[email protected]> | 2025-01-04 00:05:35 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-04 05:05:35 +0000 |
| commit | 3d701943d17e9b34820ca2f26e1f63a5031584da (patch) | |
| tree | a607cca29613a2c2d592b24f13145500be44a991 | |
| parent | 8f1c8eea5f2d647ead5a2fcebd0f2fb98b6e976c (diff) | |
feat: allow for querying multiple substituters (#49)
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/cli.rs | 11 | ||||
| -rw-r--r-- | src/command.rs | 13 |
3 files changed, 18 insertions, 8 deletions
@@ -14,7 +14,7 @@ Arguments: Options: -c, --configuration <CONFIGURATION> Flake reference pointing to a NixOS or nix-darwin configuration - -b, --binary-cache <BINARY_CACHE> URL of the substituter to check [default: https://cache.nixos.org] + -b, --binary-caches <BINARY_CACHES> URLs of the substituters to check (can be passed more than once) [default: https://cache.nixos.org] -f, --flake <FLAKE> Flake reference of nixpkgs (or other package repository) [default: nixpkgs] -s, --show-missing Show a list of store paths not found in the substituter -h, --help Print help @@ -11,9 +11,14 @@ pub struct Cli { #[arg(short, long, conflicts_with("installables"))] pub configuration: Option<String>, - /// URL of the substituter to check - #[arg(short, long, default_value = "https://cache.nixos.org")] - pub binary_cache: String, + /// URLs of the substituters to check (can be passed more than once) + #[arg( + alias = "binary-cache", + short, + long, + default_value = "https://cache.nixos.org" + )] + pub binary_caches: Vec<String>, /// Flake reference of nixpkgs (or other package repository) #[arg(short, long, default_value = "nixpkgs")] diff --git a/src/command.rs b/src/command.rs index 8e8a312..be1dd4c 100644 --- a/src/command.rs +++ b/src/command.rs @@ -26,7 +26,7 @@ impl Run for crate::Cli { resolve_installables(installables).await? }; - check_store_paths(&self.binary_cache, &store_paths, self.show_missing).await?; + check_store_paths(&self.binary_caches, &store_paths, self.show_missing).await?; Ok(()) } @@ -63,12 +63,12 @@ async fn resolve_installables(installables: Vec<String>) -> Result<Vec<String>> #[allow(clippy::cast_precision_loss)] #[instrument(skip(store_paths))] async fn check_store_paths( - binary_cache: &str, + binary_caches: &Vec<String>, store_paths: &Vec<String>, show_missing: bool, ) -> Result<()> { let num_store_paths = store_paths.len(); - println!("🌡️ Checking for {num_store_paths} store path(s) in {binary_cache}",); + println!("🌡️ Checking for {num_store_paths} store path(s) in: {binary_caches:?}"); let http = <http::Client as http::Ext>::default(); let progress_bar = ProgressBar::new(num_store_paths as u64).with_style(progress_style()?); @@ -78,7 +78,12 @@ async fn check_store_paths( let http = &http; let progress_bar = &progress_bar; async move { - let has_store_path = http.has_store_path(binary_cache, store_path).await?; + let mut has_store_path = false; + for binary_cache in binary_caches { + if http.has_store_path(binary_cache, store_path).await? { + has_store_path = true; + } + } progress_bar.inc(1); anyhow::Ok((has_store_path, store_path.as_str())) |
