add option to disable cache.nixos.org

This commit is contained in:
cy 2025-05-07 17:14:25 -04:00
parent 68df59ad25
commit ce0e70f95a
3 changed files with 11 additions and 9 deletions

View file

@ -55,8 +55,9 @@ pub struct PushArgs {
#[arg(long)]
endpoint: Option<String>,
/// 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

View file

@ -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<Self> {
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"))?);
}