From 0f38ba08ea1f176b25d0dc407e4b12d3ee1b277a Mon Sep 17 00:00:00 2001 From: Paul-Nicolas Madelaine Date: Wed, 18 Dec 2024 16:50:25 +0100 Subject: [PATCH 1/2] fix --- crate2nix/src/test.rs | 1 + crate2nix/tests/self_build_up_to_date.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/crate2nix/src/test.rs b/crate2nix/src/test.rs index 8d1774b1..530864a5 100644 --- a/crate2nix/src/test.rs +++ b/crate2nix/src/test.rs @@ -13,6 +13,7 @@ pub fn generate_config() -> crate::GenerateConfig { output: "Cargo.nix".into(), use_cargo_lock_checksums: true, read_crate_hashes: true, + registry_hashes_json: "registry-hashes.json".into(), } } diff --git a/crate2nix/tests/self_build_up_to_date.rs b/crate2nix/tests/self_build_up_to_date.rs index 7e5d0130..9450faf2 100644 --- a/crate2nix/tests/self_build_up_to_date.rs +++ b/crate2nix/tests/self_build_up_to_date.rs @@ -34,6 +34,7 @@ fn self_up_to_date() { other_metadata_options: vec![], use_cargo_lock_checksums: true, read_crate_hashes: true, + registry_hashes_json: PathBuf::from("./registry-hashes.json"), }, ) .unwrap(); @@ -79,6 +80,9 @@ fn assert_up_to_date(project_dir: &Path) { other_metadata_options: vec![], use_cargo_lock_checksums: true, read_crate_hashes: true, + registry_hashes_json: PathBuf::from("../") + .join(project_dir) + .join("./registry-hashes.json"), }; let metadata = BuildInfo::for_config( &GenerateInfo { From 04ffee42f2e1ca64971bddd3a845b0a3cf55c689 Mon Sep 17 00:00:00 2001 From: Paul-Nicolas Madelaine Date: Wed, 18 Dec 2024 17:21:03 +0100 Subject: [PATCH 2/2] fix --- crate2nix/src/config.rs | 9 +-------- crate2nix/src/lib.rs | 2 +- crate2nix/src/prefetch.rs | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/crate2nix/src/config.rs b/crate2nix/src/config.rs index 4346d857..25eb8c55 100644 --- a/crate2nix/src/config.rs +++ b/crate2nix/src/config.rs @@ -196,14 +196,7 @@ impl Display for Source { sha256, registry, .. - } => write!( - f, - "{} {} from {}: {}", - name, - version, - registry.to_string(), - sha256 - ), + } => write!(f, "{} {} from {}: {}", name, version, registry, sha256), Source::Git { url, rev, sha256 } => write!(f, "{}#{} via git: {}", url, rev, sha256), Source::Nix { file, attr: None } => write!(f, "{}", file), Source::Nix { diff --git a/crate2nix/src/lib.rs b/crate2nix/src/lib.rs index 1d3a83ef..72812c6f 100644 --- a/crate2nix/src/lib.rs +++ b/crate2nix/src/lib.rs @@ -225,7 +225,7 @@ fn prefetch_and_fill_registries( config: &GenerateConfig, default_nix: &mut BuildInfo, ) -> Result<(), Error> { - default_nix.registries = prefetch::prefetch_registries(config, &mut default_nix.crates) + default_nix.registries = prefetch::prefetch_registries(config, &default_nix.crates) .map_err(|e| format_err!("while prefetching crates for calculating sha256: {}", e))?; Ok(()) diff --git a/crate2nix/src/prefetch.rs b/crate2nix/src/prefetch.rs index 14ea9e32..7357e1b5 100644 --- a/crate2nix/src/prefetch.rs +++ b/crate2nix/src/prefetch.rs @@ -202,7 +202,7 @@ pub fn prefetch_registries( &[&format!( "{}{}config.json", e.key(), - if e.key().ends_with("/") { "" } else { "/" } + if e.key().ends_with('/') { "" } else { "/" } )], )?; e.insert(out);