Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example on bringing in Rust system dependencies (specifically OpenSSL) #207

Closed
igrekun opened this issue Mar 23, 2022 · 2 comments · Fixed by #305
Closed

Example on bringing in Rust system dependencies (specifically OpenSSL) #207

igrekun opened this issue Mar 23, 2022 · 2 comments · Fixed by #305
Labels
P3 minor: not priorized type: feature request

Comments

@igrekun
Copy link

igrekun commented Mar 23, 2022

Is your feature request related to a problem? Please describe.
Axum brings in zlib dependency which could be solved by modifying shell.nix in rust toolchain example like this

{ pkgs ? import ./nixpkgs.nix { } }:

pkgs.mkShell { nativeBuildInputs = [ pkgs.bazel_4 pkgs.zlib ]; }

For example elasticsearch crate uses native-tls which requires libssl and fails to find it
error while loading shared libraries: libssl.so.1.1
Using rusttsl in features weirdly results in the same error.

Describe the solution you'd like
Include example on building Rust library / binary with OpenSSL, probably generic example for managing dynamically linked system dependencies.

Describe alternatives you've considered
The same trick that I did with zlib didn't cut it for OpenSSL, besides OpenSSL seems present in default shell configuration, it just doesn't resolve with rust toolchain.

{ pkgs ? import ./nixpkgs.nix { } }:

pkgs.mkShell { nativeBuildInputs = [ pkgs.bazel_4 pkgs.zlib pkgs.openssl ]; }

Additional context
Full list of Cargo.toml dependencies:

[dependencies]
axum = "0.4.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.68"
tokio = { version = "1.0", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
elasticsearch = "7.14.0-alpha.1"
url = { version = "2", features = ["serde"] }
@aherrmann aherrmann added type: feature request P3 minor: not priorized labels Mar 24, 2022
@aherrmann
Copy link
Member

Thanks for raising this! Adding it to the Nix shell would not propagate it into the build actions themselves. For that the dependency needs to be declared in Bazel.

@AlexeiDrake didn't you have a working example of something like this?

@igrekun
Copy link
Author

igrekun commented Mar 24, 2022

Could it have something to do with how cargo works under nix + bazel?

Adding zlib to nix shell fixed rust unable to find its headers. Missing zlib failed during nix-shell --command 'bazel build my_target'
while with openssl it builds but fails on nix-shell --command 'bazel run my_target'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 minor: not priorized type: feature request
Projects
None yet
2 participants