Skip to content

Commit

Permalink
devenv: reduce cache misses from non-deterministic cache key order
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed Dec 23, 2024
1 parent 1b397b7 commit cfe2a0b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions devenv/src/cnix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ impl<'a> Nix<'a> {
options: &Options<'a>,
) -> Result<std::process::Command> {
let mut final_args = Vec::new();
let known_keys;
let pull_caches;
let known_keys_str;
let pull_caches_str;
let mut push_cache = None;

if !self.global_options.offline {
Expand All @@ -463,28 +463,31 @@ impl<'a> Nix<'a> {
push_cache = cachix_caches.caches.push.clone();
// handle cachix.pull
if !cachix_caches.caches.pull.is_empty() {
pull_caches = cachix_caches
let mut pull_caches = cachix_caches
.caches
.pull
.iter()
.map(|cache| format!("https://{}.cachix.org", cache))
.collect::<Vec<String>>()
.join(" ");
.collect::<Vec<String>>();
pull_caches.sort();
pull_caches_str = pull_caches.join(" ");
final_args.extend_from_slice(&[
"--option",
"extra-substituters",
&pull_caches,
&pull_caches_str,
]);
known_keys = cachix_caches

let mut known_keys = cachix_caches
.known_keys
.values()
.cloned()
.collect::<Vec<String>>()
.join(" ");
.collect::<Vec<String>>();
known_keys.sort();
known_keys_str = known_keys.join(" ");
final_args.extend_from_slice(&[
"--option",
"extra-trusted-public-keys",
&known_keys,
&known_keys_str,
]);
}
}
Expand Down

0 comments on commit cfe2a0b

Please sign in to comment.