Jump to content

Rust: Difference between revisions

418 bytes added ,  1 May 2022
Longer example, fixed the section title
imported>A-m-joseph
(Link to the best example of overriding a rust dependency that I could find.)
imported>A-m-joseph
(Longer example, fixed the section title)
Line 129: Line 129:
[https://www.srid.ca/rust-nix This] blog post shows how to do it using <code>crate2nix</code>.
[https://www.srid.ca/rust-nix This] blog post shows how to do it using <code>crate2nix</code>.


== Overriding rust libraries used by a rust package ==
== Using overrideArgs with Rust Packages ==


This is a bit tricky, you can't just use <code>overrideAttrs</code>.  [https://discourse.nixos.org/t/is-it-possible-to-override-cargosha256-in-buildrustpackage/4393/3 Here] is one example of how to do it.
This is a bit tricky, you can't just use <code>overrideArgs</code>.  [https://discourse.nixos.org/t/is-it-possible-to-override-cargosha256-in-buildrustpackage/4393/3 Here] is one example of how to do it. The trick is to use two nested calls to <code>overrideAttrs</code>; the outer call overrides the <code>cargoDeps</code> attribute, the inner call overrides the dependency:
 
<syntaxHighlight lang="nix">
overlays = [
  (final: prev: {
    some-nixpkgs-package = prev.some-nixpkgs-package.overrideAttrs (oldAttrs: {
      cargoDeps = oldAttrs.cargoDeps.overrideAttrs (_: {
        # ...
      });
    });
  })
];
</syntaxHighlight>


== Neovim Completion ==
== Neovim Completion ==
Anonymous user