From 2bcd86656fdb53e9e28bfbb87c55a1223847b129 Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Mon, 16 Sep 2024 09:59:47 -0700 Subject: [PATCH] nix.conf: move write for 'fallback', always set it --- magic-nix-cache/src/main.rs | 5 +++++ magic-nix-cache/src/pbh.rs | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/magic-nix-cache/src/main.rs b/magic-nix-cache/src/main.rs index aeecc2c..515c829 100644 --- a/magic-nix-cache/src/main.rs +++ b/magic-nix-cache/src/main.rs @@ -222,6 +222,11 @@ async fn main_cli() -> Result<()> { .open(&nix_conf_path) .with_context(|| "Creating nix.conf")?; + // always enable fallback, first + nix_conf + .write_all(b"fallback = true\n") + .with_context(|| "Setting fallback in nix.conf")?; + let store = Arc::new(NixStore::connect()?); let narinfo_negative_cache = Arc::new(RwLock::new(HashSet::new())); diff --git a/magic-nix-cache/src/pbh.rs b/magic-nix-cache/src/pbh.rs index cda2ad5..43f5cc3 100644 --- a/magic-nix-cache/src/pbh.rs +++ b/magic-nix-cache/src/pbh.rs @@ -186,13 +186,7 @@ pub async fn setup_legacy_post_build_hook( /* Update nix.conf. */ nix_conf - .write_all( - format!( - "fallback = true\npost-build-hook = {}\n", - post_build_hook_script.display() - ) - .as_bytes(), - ) + .write_all(format!("post-build-hook = {}\n", post_build_hook_script.display()).as_bytes()) .with_context(|| "Writing to nix.conf")?; Ok(())