Skip to content

Commit 1426335

Browse files
authored
Merge pull request #1294 from dbarrosop/nix-darwin
fix nix environment
2 parents 49bbeee + e6bc13f commit 1426335

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

flake.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@
1414
flake-utils.lib.eachDefaultSystem (system:
1515
let
1616
pkgs = nixpkgs.legacyPackages.${system};
17+
18+
cargoBuildInputs = with pkgs; lib.optionals stdenv.isDarwin [
19+
darwin.apple_sdk.frameworks.CoreServices
20+
];
21+
1722
rustlings =
1823
pkgs.rustPlatform.buildRustPackage {
1924
name = "rustlings";
2025
version = "5.3.0";
2126

27+
buildInputs = cargoBuildInputs;
28+
2229
src = with pkgs.lib; cleanSourceWith {
2330
src = self;
2431
# a function that returns a bool determining if the path should be included in the cleaned source
@@ -42,12 +49,16 @@
4249
in
4350
{
4451
devShell = pkgs.mkShell {
52+
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
53+
4554
buildInputs = with pkgs; [
4655
cargo
4756
rustc
4857
rust-analyzer
4958
rustlings
50-
];
59+
rustfmt
60+
clippy
61+
] ++ cargoBuildInputs;
5162
};
5263
});
5364
}

src/project.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use glob::glob;
22
use serde::{Deserialize, Serialize};
3+
use std::env;
34
use std::error::Error;
45
use std::process::Command;
56

@@ -64,6 +65,12 @@ impl RustAnalyzerProject {
6465

6566
/// Use `rustc` to determine the default toolchain
6667
pub fn get_sysroot_src(&mut self) -> Result<(), Box<dyn Error>> {
68+
// check if RUST_SRC_PATH is set
69+
if let Ok(path) = env::var("RUST_SRC_PATH") {
70+
self.sysroot_src = path;
71+
return Ok(());
72+
}
73+
6774
let toolchain = Command::new("rustc")
6875
.arg("--print")
6976
.arg("sysroot")

0 commit comments

Comments
 (0)