Rust: Difference between revisions
imported>Nyarly No edit summary |
imported>TheSirC Adding Emacs support |
||
Line 32: | Line 32: | ||
}) | }) | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Emacs integration == | |||
Making Emacs use certain version of libraries can be tricky, in particular for example OpenSSL might not be found ''even'' if it is in your Nix store. Two solutions exists : | |||
* a "global" one | |||
* a per-project one | |||
Both solution relies on the usage of a library called [https://github.com/direnv/direnv/wiki/Nix direnv] and its package integration in Emacs [https://github.com/wbolster/emacs-direnv emacs-direnv]. | |||
=== Global solution === | |||
If you happen to have all of your Rust projects in one folder "<code>/path/to/your/rust</code>" then placing a file <code>/path/to/your/rust/.envrc</code> with this content : | |||
<syntaxHighlight lang="shell"> | |||
use_nix | |||
</syntaxHighlight> | |||
and another file <code>/path/to/your/rust/default.nix</code> : | |||
<syntaxHighlight lang="Nix"> | |||
let | |||
moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz); | |||
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; }; | |||
ruststable = (nixpkgs.latest.rustChannels.stable.rust.override { extensions = [ "rust-src" "rls-preview" "rust-analysis" "rustfmt-preview" ];}); | |||
in | |||
with nixpkgs; | |||
stdenv.mkDerivation { | |||
name = "rust"; | |||
buildInputs = [ openssl nasm rustup ruststable cmake zlib ]; | |||
shellHook = '' | |||
export OPENSSL_DIR="${openssl.dev}" | |||
export OPENSSL_LIB_DIR="${openssl.out}/lib" | |||
''; | |||
} | |||
</syntaxHighlight> | |||
will, for example, grant you a free acces to OpenSSL ! Feel free to override this to your liking ! | |||
=== Per-project solution === | |||
For a more granular solution to this problem a more in-depth review of [https://github.com/direnv/direnv/wiki/Nix#persistent-shell-for-speeding-things-up the direnv wiki] will be poorly be needed ! |