thomson

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

rustup.nix (1856B)


      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       probe-rs-tools
     18 #      sops
     19     ];
     20     buildInputs = with pkgs; [
     21       clang
     22       # Replace llvmPackages with llvmPackages_X, where X is the latest LLVM version (at the time of writing, 16)
     23       llvmPackages.bintools
     24       rustup
     25     ];
     26     RUSTC_VERSION = overrides.toolchain.channel;
     27     # https://github.com/rust-lang/rust-bindgen#environment-variables
     28     LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
     29     shellHook = ''
     30       export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
     31       export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
     32       '';
     33     # Add precompiled library to rustc search path
     34     RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
     35       # add libraries here (e.g. pkgs.libvmi)
     36     ]);
     37     LD_LIBRARY_PATH = libPath;
     38     # Add glibc, clang, glib, and other headers to bindgen search path
     39     BINDGEN_EXTRA_CLANG_ARGS =
     40     # Includes normal include path
     41     (builtins.map (a: ''-I"${a}/include"'') [
     42       # add dev libraries here (e.g. pkgs.libvmi.dev)
     43       pkgs.glibc.dev
     44     ])
     45     # Includes with special directory paths
     46     ++ [
     47       ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
     48       # ''-I"${pkgs.glib.dev}/include/glib-2.0"''
     49       # ''-I${pkgs.glib.out}/lib/glib-2.0/include/''
     50     ];
     51   }