Open traxys opened 2 years ago
I guess the rust language extension was not intended to work out of the box with this overlay.
I have something working with a new rust.nix
import:
pkgs.devshell.mkShell {
imports = [ ./rust.nix ];
language.rust.packageSet = pkgs.rust-bin.stable.latest;
language.rust.tools = [
"rustc"
"cargo"
"clippy"
];
};
where rust.nix
is a slightly modified copy of https://github.com/numtide/devshell/blob/master/extra/language/rust.nix:
{ lib, config, pkgs, ... }:
let
cfg = config.language.rust;
in
with lib;
{
options.language.rust = {
packageSet = mkOption {
# FIXME: how to make the selection possible in TOML?
type = types.attrs;
default = pkgs.rustPackages;
defaultText = "pkgs.rustPlatform";
description = "Which rust package set to use";
};
tools = mkOption {
type = types.listOf types.str;
default = [
"rustc"
"cargo"
"clippy"
"rustfmt"
];
description = "Which rust tools to pull from the platform package set";
};
};
config = {
env = [{
# Used by tools like rust-analyzer
name = "RUST_SRC_PATH";
value = "${cfg.packageSet.rust-src}/lib/rustlib/src/rust/library";
}];
devshell.packages = map (tool: cfg.packageSet.${tool}) cfg.tools;
};
}
When using devshell in rust projects I'd lke to be able to choose the rust version I want to use.
I can easily fetch any rust version using for example oxalica/rust-overlay as an overlay, but I don't understand how to set the
language.rust.packageSet
option.If I try to set it to
pkgs.rust-bin.stable.latest
then it is missingrustPlatform
, and when I try to set it toThe installation fails with an error of the kind
So it does not seem to be the right way to create such a package set. What would I need to do ?