From 30b261d17226ee2fc2181fccbd458153540af1c1 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 19 Nov 2022 13:13:19 +0000 Subject: [PATCH] Add Nix shell for Rust devel --- .envrc | 2 ++ shell.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .envrc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..c9293c0 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use nix + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..dae8c4e --- /dev/null +++ b/shell.nix @@ -0,0 +1,48 @@ +{ pkgs ? import {} }: + +let + # We may need some packages from nixpkgs-unstable + #unstable = import {}; + + rust-toolchain = pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = [pkgs.rustc pkgs.cargo pkgs.rustfmt pkgs.rustPlatform.rustcSrc]; + }; +in + +pkgs.mkShell { + + buildInputs = [ + rust-toolchain + + pkgs.pkg-config + + pkgs.alsa-lib + #pkgs.libclang # ?? + ]; + + nativeBuildInputs = [ + pkgs.openssl + ]; + + # Needed for bindgen when binding to avahi + LIBCLANG_PATH="${pkgs.llvmPackages_latest.libclang.lib}/lib"; + + # Cargo culted: + # Add to rustc search path + RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ + ]); + # Add to bindgen search path + BINDGEN_EXTRA_CLANG_ARGS = + # Includes with normal include path + (builtins.map (a: ''-I"${a}/include"'') [ + ]) + # Includes with special directory paths + ++ [ + ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' + #''-I"${pkgs.glib.dev}/include/glib-2.0"'' + #''-I${pkgs.glib.out}/lib/glib-2.0/include/'' + ]; + + +}