Omnisharp-roslyn overlay

Hi, I am trying to make a first overlay. I want omnisharp-roslyn version 1.37.6, and the version in unstable is 1.37.4.
Trying to follow Overlays - NixOS Wiki and staying as close to https://github.com/NixOS/nixpkgs/blob/bde2fffbbe031c245000d33a8567ba6b90d17129/pkgs/development/tools/omnisharp-roslyn/default.nix as possible, I added the following to configuration.nix, but as you can read in the comments the sha256 attribute is incorrect:

nixpkgs.overlays =
    [ (self: super:
      {
            omnisharp-roslyn = super.omnisharp-roslyn.overrideAttrs (old: {
                src = pkgs.fetchurl {
                    url = "https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.37.6/omnisharp-mono.tar.gz";
                    
                    # according to the wiki, I could use the below sha256 to get the correct one.
                    # sha256 = "0000000000000000000000000000000000000000000000000000";
                     
                    # The rebuild failed as expected, and suggested this hash:
                    # sha256 = "pebAU2s1ro+tq7AnaVKOIDoTjxM4dZwCRo1kJoARW+Y";
                    #However, that hash is too short and any following build fails because of incorrect hash length.

                    # I instead ran 
#nix-prefetch-url https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.37.6/omnisharp-mono.tar.gz --unpack 
# This gave the following hash.
                    sha256 = "11wg5yh4s6hry43afggsfwa1w00rv14328j533ajdbvsw7di77zy";
                    # This hash is the correct length, but nix again complains that it is incorrect, and suggests the previous hash that is too short.
                };
            });
        })
    ];

What am I misunderstanding with sha256?

You need to copy the full hash provided, including the sha256- prefix.

Similar to how I have it in this example

https://github.com/NobbZ/nix-dotfiles/blob/8d47e5f0bb53f21736fd0405199539a7d036aa67/packages/erlang-ls/default.nix#L45

1 Like

Wow, I love easy fixes. It works perfectly. Thank you!

Also, nix-prefetch-url with --unpack gives you the hash of the archives content, though for fetchurl you need to provide that actual archives hash. You get it by ommiting the --unpack.

1 Like