From 3d693634b5dbb284a4c4712b45215005287bb92c Mon Sep 17 00:00:00 2001 From: David Barroso Date: Sat, 10 Dec 2022 13:23:15 +0100 Subject: [PATCH 1/4] fix nix build on Darwin --- flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake.nix b/flake.nix index 15c82b7..4cfe7d9 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,10 @@ name = "rustlings"; version = "5.2.1"; + buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreServices + ]; + src = with pkgs.lib; cleanSourceWith { src = self; # a function that returns a bool determining if the path should be included in the cleaned source From 1ce671528e40eab7f5d09f6579537a297858d284 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Sat, 10 Dec 2022 13:57:26 +0100 Subject: [PATCH 2/4] add missing RUST_SRC_PATH --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 4cfe7d9..3fabe0f 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,8 @@ in { devShell = pkgs.mkShell { + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + buildInputs = with pkgs; [ cargo rustc From b2df015fe6c76203d55ee1c916b4f3a27b327d67 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Sat, 10 Dec 2022 14:05:44 +0100 Subject: [PATCH 3/4] when generating lsp config use RUST_SRC_PATH if set --- src/project.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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> { + // 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") From e6bc13ff04502066540db427780c442fe9690295 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Tue, 3 Jan 2023 08:26:12 +0100 Subject: [PATCH 4/4] added common cargoBuildInputs to all flake outputs --- flake.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 3fabe0f..4fec6ac 100644 --- a/flake.nix +++ b/flake.nix @@ -14,14 +14,17 @@ 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.2.1"; - buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.CoreServices - ]; + buildInputs = cargoBuildInputs; src = with pkgs.lib; cleanSourceWith { src = self; @@ -53,7 +56,9 @@ rustc rust-analyzer rustlings - ]; + rustfmt + clippy + ] ++ cargoBuildInputs; }; }); }