Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cargoPatches? #192

Open
tv42 opened this issue Sep 10, 2021 · 3 comments
Open

Support cargoPatches? #192

tv42 opened this issue Sep 10, 2021 · 3 comments

Comments

@tv42
Copy link

tv42 commented Sep 10, 2021

rustPlatform.buildRustPackage supports a cargoPatches option, that can be used to insert a Cargo.lock into upstream tarballs that don't contain it. It would be nice if the same was possible with naersk.

Alternatively, and more generically, this could be solved with a applyPatches { src; patches = []; } derivation -- but I'm not aware of such existing. I guess I'm writing that myself, next...

@tv42
Copy link
Author

tv42 commented Sep 10, 2021

For anyone else stumbling on this, here's the generic patch apply trick:

  src = pkgs.stdenv.mkDerivation {
    name = "foo";
    src = origSrc;
    patches = [
      ./foo-cargo-lock.diff
    ];
    dontConfigure = true;
    dontBuild = true;
    doCheck = false;
    installPhase = ''
      cp -r . $out
    '';
  };

@paulyoung
Copy link

@tv42 does this approach allow patching or otherwise modifying a crate that exists as a dependency in Cargo.toml?

If so, please could you help me understand how to do that?

@tv42
Copy link
Author

tv42 commented Aug 24, 2022

@paulyoung This method seems to be for patching the source being built itself. To patch dependencies, you'd need to e.g. change the Cargo.toml lines to point to something else, or something like that -- I don't know if naersk has any mechanism for replacing dependencies.

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

No branches or pull requests

2 participants