rustup.nix (1829B)
1 { pkgs ? import <nixpkgs> {} }: 2 let 3 overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); 4 libPath = with pkgs; lib.makeLibraryPath [ 5 # load external libraries that you need in your rust project here 6 ]; 7 python = (pkgs.python3.withPackages (python-pkgs: [ 8 python-pkgs.pynacl 9 python-pkgs.zeroconf 10 python-pkgs.bleak 11 ])); 12 in 13 pkgs.mkShell rec { 14 nativeBuildInputs= with pkgs; [ 15 openssl 16 rustup 17 sops 18 ]; 19 buildInputs = with pkgs; [ 20 clang 21 # Replace llvmPackages with llvmPackages_X, where X is the latest LLVM version (at the time of writing, 16) 22 llvmPackages.bintools 23 rustup 24 ]; 25 RUSTC_VERSION = overrides.toolchain.channel; 26 # https://github.com/rust-lang/rust-bindgen#environment-variables 27 LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; 28 shellHook = '' 29 export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin 30 export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ 31 ''; 32 # Add precompiled library to rustc search path 33 RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ 34 # add libraries here (e.g. pkgs.libvmi) 35 ]); 36 LD_LIBRARY_PATH = libPath; 37 # Add glibc, clang, glib, and other headers to bindgen search path 38 BINDGEN_EXTRA_CLANG_ARGS = 39 # Includes normal include path 40 (builtins.map (a: ''-I"${a}/include"'') [ 41 # add dev libraries here (e.g. pkgs.libvmi.dev) 42 pkgs.glibc.dev 43 ]) 44 # Includes with special directory paths 45 ++ [ 46 ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' 47 ''-I"${pkgs.glib.dev}/include/glib-2.0"'' 48 ''-I${pkgs.glib.out}/lib/glib-2.0/include/'' 49 ]; 50 }