diff options
| author | liv <mokou@fastmail.com> | 2023-01-03 10:20:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-03 10:20:47 +0100 |
| commit | 142633533eaa218091600566a1284c007c21d46e (patch) | |
| tree | 4082c718a756a787db00285baacc3257e30cde57 | |
| parent | 49bbeeefaee9e65dec141d6177589481d3e0fd58 (diff) | |
| parent | e6bc13ff04502066540db427780c442fe9690295 (diff) | |
Merge pull request #1294 from dbarrosop/nix-darwin
fix nix environment
| -rw-r--r-- | flake.nix | 13 | ||||
| -rw-r--r-- | src/project.rs | 7 |
2 files changed, 19 insertions, 1 deletions
@@ -14,11 +14,18 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; + + cargoBuildInputs = with pkgs; lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreServices + ]; + rustlings = pkgs.rustPlatform.buildRustPackage { name = "rustlings"; version = "5.3.0"; + buildInputs = cargoBuildInputs; + src = with pkgs.lib; cleanSourceWith { src = self; # a function that returns a bool determining if the path should be included in the cleaned source @@ -42,12 +49,16 @@ in { devShell = pkgs.mkShell { + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + buildInputs = with pkgs; [ cargo rustc rust-analyzer rustlings - ]; + rustfmt + clippy + ] ++ cargoBuildInputs; }; }); } diff --git a/src/project.rs b/src/project.rs index 0df00b9..a6e3acf 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,5 +1,6 @@ use glob::glob; use serde::{Deserialize, Serialize}; +use std::env; use std::error::Error; use std::process::Command; @@ -64,6 +65,12 @@ impl RustAnalyzerProject { /// Use `rustc` to determine the default toolchain pub fn get_sysroot_src(&mut self) -> Result<(), Box<dyn Error>> { + // check if RUST_SRC_PATH is set + if let Ok(path) = env::var("RUST_SRC_PATH") { + self.sysroot_src = path; + return Ok(()); + } + let toolchain = Command::new("rustc") .arg("--print") .arg("sysroot") |
