nix-community / fenix

Rust toolchains and rust-analyzer nightly for Nix [maintainer=@figsoda]
Mozilla Public License 2.0
667 stars 42 forks source link

Custom rust version support #158

Open srounce opened 3 months ago

srounce commented 3 months ago

It'd be great to be able to use Fenix to use custom rust toolchains such as esp-rs/rust. It's currently not clear how to go about doing this, or if it's even possible at all.

srounce commented 3 months ago

Okay so I sort of found a solution to this by taking the existing stable manifest and then merging a partial manifest of the custom toolchain over the top of it. In my case my partial manifest replaced the URLs and hashes for rust and rust-src:

{ pkgs, inputs, ... }:
let
  system = pkgs.stdenv.system;

  rustToolchainManifest = pkgs.lib.recursiveUpdate
    (builtins.fromJSON (builtins.readFile "${inputs.fenix}/data/stable.json"))
    (builtins.fromJSON (builtins.readFile ./esp-rs.json));

  toolchainAttrs = inputs.fenix.packages.${system}.fromManifest rustToolchainManifest;
in
{
  toolchain = toolchainAttrs.completeToolchain;
}

I'm still wondering is there a better way to go about this?

DavSanchez commented 3 months ago

I'm very interested in this. I tried your approach above @srounce and, while it mostly worked, I had some minor issues that prevented a smooth experience (tried this from aarch64-darwin). I can try to elaborate later on the specific issue I had but it would be great to know if there's a recommended way of achieving this.