From ce0e70f95a5c45ad5082364bece63bb3883191dd Mon Sep 17 00:00:00 2001 From: cy Date: Wed, 7 May 2025 17:14:25 -0400 Subject: [PATCH] add option to disable cache.nixos.org --- README.md | 4 ++-- src/lib.rs | 3 ++- src/push.rs | 13 +++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 55fdaef..f9317c8 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ Options: If unspecified, will get it form AWS_DEFAULT_REGION envar or default to us-east-1 --endpoint If unspecifed, will get it from AWS_ENDPOINT envar e.g. https://s3.example.com - --skip-signature-check - + --no-default-upstream + Do not include cache.nixos.org as upstream -h, --help Print help ``` diff --git a/src/lib.rs b/src/lib.rs index dfbab4f..fa4a43d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,8 +55,9 @@ pub struct PushArgs { #[arg(long)] endpoint: Option, + /// Do not include cache.nixos.org as upstream #[arg(long)] - skip_signature_check: bool, + no_default_upstream: bool, /// Path to upload /// e.g. ./result or /nix/store/y4qpcibkj767szhjb58i2sidmz8m24hb-hello-2.12.1 diff --git a/src/push.rs b/src/push.rs index 7c23e39..9fc043d 100644 --- a/src/push.rs +++ b/src/push.rs @@ -1,7 +1,6 @@ use std::{ collections::HashSet, fs, - iter::once, path::PathBuf, sync::{ Arc, @@ -39,11 +38,13 @@ pub struct Push { impl Push { pub async fn new(cli: &PushArgs, store: Store) -> Result { let mut upstreams = Vec::with_capacity(cli.upstreams.len() + 1); - for upstream in cli - .upstreams - .iter() - .chain(once(&"https://cache.nixos.org".to_string())) - { + if !cli.no_default_upstream { + upstreams.push( + Url::parse("https://cache.nixos.org") + .expect("default upstream must be a valid url"), + ); + } + for upstream in &cli.upstreams { upstreams .push(Url::parse(upstream).context(format!("failed to parse {upstream} as url"))?); }