I am trying to develop Rust applications on my NixOS machine. Poorly, when Emacs tries to check my project with Flycheck I get this error :
Error log
--- stdout
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
cargo:rerun-if-env-changed=OPENSSL_DIR
run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit code: 1\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `
openssl.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'openssl\' found\n"
--- stderr
thread 'main' panicked at '
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the `OPENSSL_DIR` environment variable for the
compilation process.
Make sure you also have the development packages of openssl installed.
For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
If you're in a situation where you think the directory *should* be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.
$HOST = x86_64-unknown-linux-gnu
$TARGET = x86_64-unknown-linux-gnu
openssl-sys = 0.9.36
/openssl-sys-0.9.36/build/main.rs:265:9
And that even after installing the package globally openssl
via nix-env
. I also tried to set the environment variable to the relevant part of the nix store.
All of above without success.
Is there a way to solve the issue without creating a default.nix
in each of my Rust project (read “a system-wide solution”) ?
Previous occurences
I did some search before asking about that issue both in the Rust and NixOS community and this is what I could gather :
-
this post seems to be closely related to my issue but I can not understand any answers in any of the pointed resources in the post. Are those solutions correct for a system-wide access to the library (
openssl-dev
) without having to open my editor through anix-shell
? -
this config file seems to solve (?) my issue but
- I have no idea if it is actually the case.
- I do not know how to implement it (e.g. where to put it, how to “call” it).
- this part of the wiki seems to be related to my problem but deals with it in, what I can gather to be, a granular solution rather than a global one. Am I correct ? If yes, is it possible to generalize that solution for not a per-project basis but for the system itself ?
I understand from my last bullet point that I seem to be going “against the grain” of the NixOS philosophy but it seems cumbersome to not have a system-wide configuration (at least a default base) for when a program (here my text editor) is compiling a program outside of a nix-shell. Is it the case ? Did I miss a obvious part in the Nix manual ?
Sidenote : I found a bit sad that there is no relevant section in the wiki for that. So when I find a solution I will edit it.