diff --git a/devenv/src/cli.rs b/devenv/src/cli.rs index 2d42dd686..35a541eb8 100644 --- a/devenv/src/cli.rs +++ b/devenv/src/cli.rs @@ -47,6 +47,9 @@ pub struct GlobalOptions { )] pub impure: bool, + #[arg(long, global = true, help = "Use flake cache for evaluation results.")] + pub eval_cache: bool, + #[arg( long, global = true, @@ -97,6 +100,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 638fe26ef..efac01ce9 100644 --- a/devenv/src/command.rs +++ b/devenv/src/command.rs @@ -6,7 +6,7 @@ use std::env; use std::os::unix::process::CommandExt; use std::path::Path; -const NIX_FLAGS: [&str; 12] = [ +const NIX_FLAGS: [&str; 9] = [ "--show-trace", "--extra-experimental-features", "nix-command", @@ -16,10 +16,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", ]; @@ -112,6 +108,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");