From 8fe9e78b4234b476f986077fa549df4636e404ec Mon Sep 17 00:00:00 2001 From: Seven Of Aces Date: Sun, 4 Aug 2024 10:40:25 -0700 Subject: [PATCH] add --- flake.lock | 12 +++---- hosts/blackstar/nixos/configuration.nix | 3 +- hosts/blackstar/nixos/rust-toolchain.toml | 2 ++ hosts/blackstar/nixos/shell.nix | 40 +++++++++++++++++++++++ 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 hosts/blackstar/nixos/rust-toolchain.toml create mode 100644 hosts/blackstar/nixos/shell.nix diff --git a/flake.lock b/flake.lock index 107ba9d..bf5a246 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1722519197, - "narHash": "sha256-VEdJmVU2eLFtLqCjTYJd1J7+Go8idAcZoT11IewFiRg=", + "lastModified": 1722651103, + "narHash": "sha256-IRiJA0NVAoyaZeKZluwfb2DoTpBAj+FLI0KfybBeDU0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "05405724efa137a0b899cce5ab4dde463b4fd30b", + "rev": "a633d89c6dc9a2a8aae11813a62d7c58b2c0cc51", "type": "github" }, "original": { @@ -39,11 +39,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1722421184, - "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", + "lastModified": 1722630782, + "narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", + "rev": "d04953086551086b44b6f3c6b7eeb26294f207da", "type": "github" }, "original": { diff --git a/hosts/blackstar/nixos/configuration.nix b/hosts/blackstar/nixos/configuration.nix index 32eef80..b83af6b 100644 --- a/hosts/blackstar/nixos/configuration.nix +++ b/hosts/blackstar/nixos/configuration.nix @@ -25,6 +25,7 @@ # Import your generated (nixos-generate-config) hardware configuration ./hardware-configuration.nix + ./shell.nix # Shared config ../../shared/nixos/shared_config.nix @@ -195,7 +196,7 @@ krita # code - cargo rustc # Rust + cargo rustc rustup # Rust jetbrains.rust-rover jetbrains.rider jetbrains.clion diff --git a/hosts/blackstar/nixos/rust-toolchain.toml b/hosts/blackstar/nixos/rust-toolchain.toml new file mode 100644 index 0000000..31578d3 --- /dev/null +++ b/hosts/blackstar/nixos/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable" \ No newline at end of file diff --git a/hosts/blackstar/nixos/shell.nix b/hosts/blackstar/nixos/shell.nix new file mode 100644 index 0000000..6840683 --- /dev/null +++ b/hosts/blackstar/nixos/shell.nix @@ -0,0 +1,40 @@ +{ pkgs ? import {} }: + let + overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); + libPath = with pkgs; lib.makeLibraryPath [ + # load external libraries that you need in your rust project here + ]; +in + pkgs.mkShell rec { + buildInputs = with pkgs; [ + clang + # Replace llvmPackages with llvmPackages_X, where X is the latest LLVM version (at the time of writing, 16) + llvmPackages.bintools + rustup + ]; + RUSTC_VERSION = overrides.toolchain.channel; + # https://github.com/rust-lang/rust-bindgen#environment-variables + LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; + shellHook = '' + export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin + export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ + ''; + # Add precompiled library to rustc search path + RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ + # add libraries here (e.g. pkgs.libvmi) + ]); + LD_LIBRARY_PATH = libPath; + # Add glibc, clang, glib, and other headers to bindgen search path + BINDGEN_EXTRA_CLANG_ARGS = + # Includes normal include path + (builtins.map (a: ''-I"${a}/include"'') [ + # add dev libraries here (e.g. pkgs.libvmi.dev) + pkgs.glibc.dev + ]) + # 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/'' + ]; + } \ No newline at end of file