# Cannot write a flake overlay for rust-analyzer

**URL:** https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162
**Category:** Help
**Created:** [January 12, 2024, 10:57am UTC](https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162 "2024-01-12T10:57:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tomaso](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tomaso](https://discourse.nixos.org/u/tomaso)
#### Post date: [January 12, 2024, 10:57am UTC](https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162/1 "2024-01-12T10:57:54Z")

</div>

I have [read](https://discourse.nixos.org/t/is-it-possible-to-override-cargosha256-in-buildrustpackage/4393/3) how to add an overlay for `rustBuildPackage`, however I am struggling to change github source of rust-analyzer.

```auto
          overlays = [ (import rust-overlay) (final: prev: {
              rust-analyzer-unwrapped = prev.rust-analyzer-unwrapped.overrideAttrs (old: rec {
                src = prev.fetchFromGitHub {
                      owner = "tomasol";
                      repo = "rust-analyzer";
                      rev = "ab849d87a1ef4a48a5ad121f1059a0b7a15af485";
                      sha256 = "sha256-KhukRUCbveChS1SNRs3N+DGOchTv+Ch+eVlxbJIc/rw=";
                };
                cargoDeps = old.cargoDeps.overrideAttrs (pkgs.lib.const {
                  name = "rust-analyzer-unwrapped-vendor.tar.gz";
                  inherit src;
                  outputHash = "sha256-ItyXdLHrpgEMz1BHQk49w37D8Y15L7vg0jyWurrIZLs=";
                });
              });
              cargo-component = prev.cargo-component.overrideAttrs (old: rec {
                version = "0.5.0";
                src = prev.fetchFromGitHub { 
                      owner = "bytecodealliance";
                      repo = "cargo-component";
                      rev = "v0.5.0";
                      sha256 = "sha256-P7gXfACPK63f38KzV6UVQa8MZmxEaMNxl1GZYCDM54M=";
                };
                cargoDeps = old.cargoDeps.overrideAttrs (pkgs.lib.const {
                  inherit src;
                  outputHash = "sha256-JEkupF7RhHqnxbA3DdJKGGznTzoAsPIcvYGjOfqdP4M=";
                });
              }); 
            })
          ];

```

The issue: I see that nix is downloading the right revision, but I am convinced it builds something else. `rust-analyzer --version` returns `rust-analyzer 2024-01-01`, which is the current version in unstable. I have added string `fork!` to the version in my fork.  
How can I see the actual build steps, like

1. downloading form url …
2. unpacking to folder …
3. executing build with arguments …
4. moving binaries from … to …

?

Note that `cargo-component` below works as expected, and they both seem to be set up very similarly. default.nix for [rust-analyzer](https://github.com/NixOS/nixpkgs/blob/317484b1ead87b9c1b8ac5261a8d2dd748a0492d/pkgs/development/tools/rust/rust-analyzer/default.nix) , [cargo-component](https://github.com/NixOS/nixpkgs/blob/317484b1ead87b9c1b8ac5261a8d2dd748a0492d/pkgs/development/tools/rust/cargo-component/default.nix#L37)

Full source of my [flake.nix](https://gist.github.com/tomasol/1b25d03709cefd6a3c62338caa2fe234)

---

<div class="post-metadata">

### Author: ![bowmanjd](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bowmanjd/32/11323_2.png) [@bowmanjd](https://discourse.nixos.org/u/bowmanjd)
#### Post date: [January 12, 2024, 11:57am UTC](https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162/2 "2024-01-12T11:57:11Z")

</div>

Just double-checking – are you confident the sha256 given is for the version you want?

---

<div class="post-metadata">

### Author: ![tomaso](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tomaso](https://discourse.nixos.org/u/tomaso)
#### Post date: [January 12, 2024, 12:11pm UTC](https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162/3 "2024-01-12T12:11:21Z")

</div>

I first used `pkgs.lib.fakeSha256` on both `src.sha256` and `cargoDeps.outputHash` so yes.

---

<div class="post-metadata">

### Author: ![shanesveller](https://discourse.nixos.org/user_avatar/discourse.nixos.org/shanesveller/32/11756_2.png) [@shanesveller](https://discourse.nixos.org/u/shanesveller)
#### Post date: [January 12, 2024, 12:43pm UTC](https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162/4 "2024-01-12T12:43:16Z")

</div>

[Fenix](https://github.com/nix-community/fenix) offers an overlay with nightly releases of rust-analyzer that are auto-updated by CI, and a bunch more goodies too. You may wish to study its implementation code or even just use it directly in your flake(s).

---

<div class="post-metadata">

### Author: ![tomaso](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tomaso](https://discourse.nixos.org/u/tomaso)
#### Post date: [January 14, 2024, 5:30pm UTC](https://discourse.nixos.org/t/cannot-write-a-flake-overlay-for-rust-analyzer/38162/5 "2024-01-14T17:30:58Z")

</div>

Is there a way to debug the build step by step as mentioned in my first post?
