From 23c077742565b7e35e4edbe1db47f5cc875e85bf Mon Sep 17 00:00:00 2001 From: George Thomas Date: Thu, 4 Dec 2025 09:50:55 +0000 Subject: [PATCH] Fix Rust Analyzer Previously we had warnings about sysroot, and limited feedback. This fix is from the Crane docs section about building standard library crates. --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 9a6a0b8..6121001 100644 --- a/flake.lock +++ b/flake.lock @@ -609,7 +609,28 @@ "nixpkgs": [ "haskellNix", "nixpkgs-unstable" + ], + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" ] + }, + "locked": { + "lastModified": 1764816035, + "narHash": "sha256-F0IQSmSj4t2ThkbWZooAhkCTO+YpZSd2Pqiv2uoYEHo=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "74d9abb7c5c030469f90d97a67d127cc5d76c238", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "stackage": { diff --git a/flake.nix b/flake.nix index 24e5c2f..34059ed 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,11 @@ inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.crane.url = "github:ipetkov/crane"; - outputs = { self, nixpkgs, flake-utils, haskellNix, crane }: + inputs.rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + outputs = { self, nixpkgs, flake-utils, haskellNix, crane, rust-overlay }: flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let overlays = [ @@ -15,10 +19,16 @@ evalSystem = "x86_64-linux"; }; }) + (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; haskell = pkgs.hixProject.flake { }; - rust = crane.mkLib pkgs; + rust = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.selectLatestNightlyWith ( + toolchain: toolchain.default.override { + extensions = [ "rust-src" ]; + targets = [ "x86_64-unknown-linux-gnu" ]; + } + )); in { devShells.default = pkgs.mkShell {