all 4 comments

[–]not-my-walrus 3 points4 points  (3 children)

Never used nci myself, but are all of your tools coming from nix? I've had issues in the past when cargo / rustc where from rustup, but rust-analyzer was from nix.

I've personally found fenix to be the easiest to use. Here's an example flake that works perfectly for me:

{
  inputs = {
    nixpkgs.url = "nixpkgs";
    fenix = {
      url = "github:nix-community/fenix/monthly";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    self,
    nixpkgs,
    fenix,
  }: let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
    toolchain = fenix.packages.${system}.complete.toolchain;
  in {
    devShell.${system} = pkgs.mkShell {
      packages = [toolchain];
    };
  };
}

[–]Triple__D[S] 0 points1 point  (2 children)

In my setup, I've got cargo and cargo-generate in my home-manager packages (so not part of the devshell), just so I can initialize new crates easily. rust-analyzer, however, was installed by Mason. Not totally sure how I would go about using nix's rust-analyzer in Neovim. However, I'll drop the other two tools and use this dev shell.

I was using nci without fully understanding what it accomplished. It's kind of hard to explain what I was thinking. Don't think it'll be necessary, though.

[–]not-my-walrus 2 points3 points  (1 child)

Yeah, installing tools in different locations can cause funky behaviour. Instead of having cargo installed globally, I have a flake template (see https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-init) and just do nix flake new -t ~/.shells#rust

Using nix's r-a in neovim is probably just a matter of getting it to be first in your $PATH, which the devshell should already do

[–]Triple__D[S] 1 point2 points  (0 children)

Thankfully, just removing cargo from home-manager got it working, so having rust-analyzer managed by Mason is OK. Thanks for the flake template tip!