Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

QUESTION: How to override the version of rnix-lsp being used via overlay ? #32

Closed
573 opened this issue Mar 25, 2021 · 3 comments
Closed

Comments

@573
Copy link

573 commented Mar 25, 2021

I'm trying to override the version of rnix-lsp being used via overlay. I want the bump-rnix branch.

I tried with several variations of this overlay:

self: super:
{
  rnix-lsp = super.rnix-lsp.overrideAttrs (old: {
    src =
      let 
       source = super.fetchFromGitHub { 
         owner = "nix-community";
         repo = "rnix-lsp";
         rev = "46b769da4a01232def21809734bfe9db88ded771"; # bump-rnix branch
         sha256 = "1nfglpil23ingl67j7jd64vd56klb5jlyj0pal0ndn4ipqrhnc6c"; 
       }; 
     in 
     super.runCommand "source" {} ''
       cp -R ${source} $out
       chmod +w $out/Cargo.lock
       cp ''${super.fetchurl {
        url = "https://raw.githubusercontent.com/nix-community/rnix-lsp/46b769da4a01232def21809734bfe9db88ded771/Cargo.lock";
        sha256 = "1qg5bdg5nawm7z1klfgigmpmg3qnkcws2mfh3iliam11xc10akkk";
       }} ''$out/Cargo.lock
     '';
  });
}

as well as:

self: super:
{
  rnix-lsp = super.rnix-lsp.overrideAttrs (old: {
    src =
      super.fetchFromGitHub { 
         owner = "nix-community";
         repo = "rnix-lsp";
         rev = "46b769da4a01232def21809734bfe9db88ded771"; # bump-rnix branch
         sha256 = "1nfglpil23ingl67j7jd64vd56klb5jlyj0pal0ndn4ipqrhnc6c"; 
       }; 
  });
}

but just can't get it to work.

ERROR: cargoSha256 is out of date

Cargo.lock is not the same in rnix-lsp-0.1.0-vendor.tar.gz

To fix the issue:

  1. Use "0000000000000000000000000000000000000000000000000000" as the cargoSha256 value
  2. Build the derivation and wait for it to fail with a hash mismatch
  3. Copy the 'got: sha256:' value back into the cargoSha256 field

What should I do ?

Probably related NixOS/nixpkgs#107070

@573
Copy link
Author

573 commented Mar 25, 2021

Overlay has to be this:

# ~/.config/nixpkgs/overlays/rnix-lsp.nix
self: super:
{
  rnix-lsp = super.callPackage <nixpkgs/pkgs/development/tools/rnix-lsp> {
    rustPlatform = super.rustPlatform // {
    buildRustPackage  = args:
        super.rustPlatform.buildRustPackage (args // {
        src =
            super.fetchFromGitHub { 
            owner = "nix-community";
            repo = "rnix-lsp";
            rev = "46b769da4a01232def21809734bfe9db88ded771"; # bump-rnix branch
            sha256 = "1nfglpil23ingl67j7jd64vd56klb5jlyj0pal0ndn4ipqrhnc6c"; 
        }; 
        cargoSha256 = "01j92pzq38wpaaff7nm94dhh8qwv9hg5qs8v7myx7rjs7b6fsc0b";
        });
    };
  };
}

@573 573 closed this as completed Mar 25, 2021
@573 573 changed the title QUESTION: How to bypass cargoSha256 ? QUESTION: How to override the version of rnix-lsp being used via overlay ? Mar 25, 2021
@kkharji
Copy link

kkharji commented Mar 25, 2021

Overlay has to be this:

# ~/.config/nixpkgs/overlays/rnix-lsp.nix
self: super:
{
  rnix-lsp = super.callPackage <nixpkgs/pkgs/development/tools/rnix-lsp> {
    rustPlatform = super.rustPlatform // {
    buildRustPackage  = args:
        super.rustPlatform.buildRustPackage (args // {
        src =
            super.fetchFromGitHub { 
            owner = "nix-community";
            repo = "rnix-lsp";
            rev = "46b769da4a01232def21809734bfe9db88ded771"; # bump-rnix branch
            sha256 = "1nfglpil23ingl67j7jd64vd56klb5jlyj0pal0ndn4ipqrhnc6c"; 
        }; 
        cargoSha256 = "01j92pzq38wpaaff7nm94dhh8qwv9hg5qs8v7myx7rjs7b6fsc0b";
        });
    };
  };
}

I was looking todo that the last few days but couldn't make it work 😆 . Can I define that overlay within the same file where I install lsp servers. Like what to do exchange super with, pkgs?

@573
Copy link
Author

573 commented Mar 26, 2021

@tami5 it depends on how you use overlays.
Personally I am using home-manager to manage most of my package installations, i. e. the rnix-lsp package. And for overlays I am using the folder ~/.config/nixpkgs/overlays on my system. In this folder I collect i. e. mentioned rnix-lsp.nix overlay definition file.

When I i. e. home-manager switch or nix-build an expression, the overlay expression in this file is automatically applied and I get the version of rnix-lsp declared there. For internals see references above.

Does that help already ?

EDIT:

Like what to do exchange super with, pkgs?

Originally posted by @tami5 in #32 (comment)
If I understand your usage of pkgs in your question correctly this might actually help or do you want something other than overlays ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants