Skip to content

Commit f8be742

Browse files
committed
skip download if ELECTRSD_SKIP_DOWNLOAD is set
1 parent 2676d03 commit f8be742

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ if let Ok(exe_path) = electrsd::exe_path() {
4646

4747
Startup options could be configured via the `Conf` struct using `electrsD::with_conf` or `electrsD::from_downloaded_with_conf`.
4848

49+
## Nix
50+
51+
For determinisim, in nix you cannot hit the internet within the `build.rs`. Moreover, some downstream crates cannot remove the auto-download feature from their dev-deps. In this case you can set the `ELECTRSD_SKIP_DOWNLOAD` env var and provide the electrs executable in the `PATH` (or skip the test execution).
52+
4953
## Issues with traditional approach
5054

5155
I used integration testing based on external bash script launching needed external processes, there are many issues with this approach like:

build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ mod download {
3232
}
3333

3434
pub fn download() {
35+
if std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_some() {
36+
return;
37+
}
38+
3539
if !HAS_FEATURE {
3640
return;
3741
}

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ impl Drop for ElectrsD {
346346
}
347347
}
348348

349-
/// Provide the electrs executable path if a version feature has been specified
349+
/// Provide the electrs executable path if a version feature has been specified and `ELECTRSD_SKIP_DOWNLOAD` is not set.
350350
pub fn downloaded_exe_path() -> Option<String> {
351-
if versions::HAS_FEATURE {
351+
if versions::HAS_FEATURE && std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_none() {
352352
Some(format!(
353353
"{}/electrs/{}/electrs",
354354
env!("OUT_DIR"),

0 commit comments

Comments
 (0)