commit
142633533e
13
flake.nix
13
flake.nix
|
@ -14,11 +14,18 @@
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
|
||||||
|
cargoBuildInputs = with pkgs; lib.optionals stdenv.isDarwin [
|
||||||
|
darwin.apple_sdk.frameworks.CoreServices
|
||||||
|
];
|
||||||
|
|
||||||
rustlings =
|
rustlings =
|
||||||
pkgs.rustPlatform.buildRustPackage {
|
pkgs.rustPlatform.buildRustPackage {
|
||||||
name = "rustlings";
|
name = "rustlings";
|
||||||
version = "5.3.0";
|
version = "5.3.0";
|
||||||
|
|
||||||
|
buildInputs = cargoBuildInputs;
|
||||||
|
|
||||||
src = with pkgs.lib; cleanSourceWith {
|
src = with pkgs.lib; cleanSourceWith {
|
||||||
src = self;
|
src = self;
|
||||||
# a function that returns a bool determining if the path should be included in the cleaned source
|
# a function that returns a bool determining if the path should be included in the cleaned source
|
||||||
|
@ -42,12 +49,16 @@
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
|
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
cargo
|
cargo
|
||||||
rustc
|
rustc
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
rustlings
|
rustlings
|
||||||
];
|
rustfmt
|
||||||
|
clippy
|
||||||
|
] ++ cargoBuildInputs;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
@ -64,6 +65,12 @@ impl RustAnalyzerProject {
|
||||||
|
|
||||||
/// Use `rustc` to determine the default toolchain
|
/// Use `rustc` to determine the default toolchain
|
||||||
pub fn get_sysroot_src(&mut self) -> Result<(), Box<dyn Error>> {
|
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")
|
let toolchain = Command::new("rustc")
|
||||||
.arg("--print")
|
.arg("--print")
|
||||||
.arg("sysroot")
|
.arg("sysroot")
|
||||||
|
|
Loading…
Reference in New Issue