Override rust-analyzer version

Hello!

I am trying to override rust-analyzer because 20.11 installs:

$ rust-analyzer --version
rust-analyzer 2021-10-25

This is how I am trying to do so:

  rust-analyzer = super.rust-analyzer.overrideAttrs (
    x: rec {
      version = "2022-02-28";
      cargoSha256 = "sha256-dTw6xp99uGtGp6YuqAX3r3GDD6Wto3KHTaO2DUUE2FA=";

      src = super.fetchFromGitHub {
        owner = "rust-analyzer";
        repo = "rust-analyzer";
        rev = version;
        sha256 = "sha256-GQ1cPO4povnozLl0MTFs0ZXpmBn+AZeFWQVnxHHWf9g=";
      };
    }
  );

I do not get any error but rust-analyzer does not change.
Thanks

The update probably succeeded correctly, though you forgot to tell the rust analyzed that it got updated, you probably need to update all the other fields refering to version to get also the output right.

Thanks @NobbZ ! I am far away to know what I am doing, just to be clear. I have added the RUST_ANALYZER_REV as part of the override but I can’t see a change

  rust-analyzer = super.rust-analyzer.overrideAttrs (
    x: rec {
      version = "2022-02-28";
      cargoSha256 = "sha256-dTw6xp99uGtGp6YuqAX3r3GDD6Wto3KHTaO2DUUE2FA=";
      RUST_ANALYZER_REV = "2022-02-28";

      src = super.fetchFromGitHub {
        owner = "rust-analyzer";
        repo = "rust-analyzer";
        rev = "2022-02-28";
        sha256 = "sha256-GQ1cPO4povnozLl0MTFs0ZXpmBn+AZeFWQVnxHHWf9g=";
      };
    }
  );

I checked the rust-analyzer binary and it comes from this directory ll /nix/store/bw528h04d9a1ymfnqanqimnxai1y3qb6-rust-analyzer-2021-10-25 that contains the “old” version 2021-10-25.

I created a PR with my code if it can help you wip(nixos): override rust-analyzer by gianarb ¡ Pull Request #15 ¡ gianarb/dotfiles ¡ GitHub

Then your overlay isn’t used at all.

Thanks! I am not sure if you had the possibility to look at my PR but it sound in use. I have tried to change the name for the overwritten derivation to something unique and it picks it up.

I am missing something but I think it is used by the system

I skimmed the overall repository, and haven’t found a clue where the overlay get applied.

I am not sure if this is what you are looking for but here is where I import the overlay file:

Other packages like weechat are correctly overwritten for what I can tell

Okay, I have indeed overlooked that one, and again I skimmed (some) of the imported modules, basically the roles, and this time I didn’t find where you install the analyser.

As part of this PR wip(nixos): override rust-analyzer by gianarb ¡ Pull Request #15 ¡ gianarb/dotfiles ¡ GitHub

I have to play with it a bit when at a PC, though now as I see the override cargoSha256 I remember that it wasn’t that easy to override rust programs.

1 Like

Ok, I realized I was doing something silly. I fixed my issue important the unstable channel. And now I install rust-analyzer from it.

I got to this solution because I changed the cargoSha256 from a random value and NixOS built the new version but it failed along the way, probably because I had to apply different patches.

I am kind of curious to know what I am doing wrong with the overlay but I am where I was trying to go!

Thanks a lot!

Okay, so I will not dig much into the issue then and consider it done.

In general though allow me to give you another advice:

Consider installing rust and it’s tools on a per project basis through the Mozilla or oxalica overlays.

Thanks! This is a topic I am trying to figure as well! I will dig into it!