diff --git a/Cargo.toml b/Cargo.toml index d22589e..11909dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ categories = ["cryptography::cryptocurrencies", "development-tools::testing"] [dependencies] bitcoind = { version = "0.34.0" } electrum-client = { version = "0.19.0", default-features = false } -nix = { version = "0.25.0" } log = "0.4" which = "4.2.5" diff --git a/README.md b/README.md index 5efb9da..4c49da9 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ if let Ok(exe_path) = electrsd::exe_path() { Startup options could be configured via the `Conf` struct using `electrsD::with_conf` or `electrsD::from_downloaded_with_conf`. +## Nix + +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). + ## Issues with traditional approach I used integration testing based on external bash script launching needed external processes, there are many issues with this approach like: diff --git a/build.rs b/build.rs index b8a3a81..727a139 100644 --- a/build.rs +++ b/build.rs @@ -32,6 +32,10 @@ mod download { } pub fn download() { + if std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_some() { + return; + } + if !HAS_FEATURE { return; } diff --git a/src/lib.rs b/src/lib.rs index 5892230..3a737b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -346,9 +346,9 @@ impl Drop for ElectrsD { } } -/// Provide the electrs executable path if a version feature has been specified +/// Provide the electrs executable path if a version feature has been specified and `ELECTRSD_SKIP_DOWNLOAD` is not set. pub fn downloaded_exe_path() -> Option { - if versions::HAS_FEATURE { + if versions::HAS_FEATURE && std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_none() { Some(format!( "{}/electrs/{}/electrs", env!("OUT_DIR"),