From 33c932f0ef82bfaa342d26c34ca7010f76f9a282 Mon Sep 17 00:00:00 2001 From: Janez T Date: Mon, 17 Jun 2024 15:14:16 +0200 Subject: [PATCH] Allow caching ovveride for nix flakes --- devenv/src/cli.rs | 4 ++++ devenv/src/command.rs | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/devenv/src/cli.rs b/devenv/src/cli.rs index ae1a7e8b5..d6f630d08 100644 --- a/devenv/src/cli.rs +++ b/devenv/src/cli.rs @@ -46,6 +46,9 @@ pub struct GlobalOptions { )] pub impure: bool, + #[arg(long, global = true, help = "Use flake cache.")] + pub eval_cache: bool, + #[arg( long, global = true, @@ -96,6 +99,7 @@ impl Default for GlobalOptions { cores: 2, system: default_system(), impure: false, + eval_cache: false, offline: false, clean: None, nix_debugger: false, diff --git a/devenv/src/command.rs b/devenv/src/command.rs index 115ae5e28..71f7dcc0e 100644 --- a/devenv/src/command.rs +++ b/devenv/src/command.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use std::env; use std::os::unix::process::CommandExt; -const NIX_FLAGS: [&str; 12] = [ +const NIX_FLAGS: [&str; 9] = [ "--show-trace", "--extra-experimental-features", "nix-command", @@ -15,10 +15,6 @@ const NIX_FLAGS: [&str; 12] = [ "--option", "warn-dirty", "false", - // flake caching is too aggressive - "--option", - "eval-cache", - "false", // always build all dependencies and report errors at the end "--keep-going", ]; @@ -117,6 +113,11 @@ impl Devenv { let max_jobs = self.global_options.max_jobs.to_string(); flags.push(&max_jobs); + flags.push("--option"); + flags.push("eval-cache"); + let eval_cache = self.global_options.eval_cache.to_string(); + flags.push(&eval_cache); + // handle --nix-option key value for chunk in self.global_options.nix_option.chunks_exact(2) { flags.push("--option");