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 patch: protocol with local patches without needing to specify outputHash in manifest #2

Open
madjam002 opened this issue Oct 27, 2022 · 6 comments

Comments

@madjam002
Copy link
Owner

The package could be fetched in a FOD derivation and then patched in a separate derivation with no outputHash needed.

@frantisekhanzlikbl
Copy link
Contributor

Is there currently any way to use local patches at all? I don't mind specifying outputHash manually, but as much as I've tried, I didn't manage to make patching work at all.

@madjam002
Copy link
Owner Author

Yes patches are supported, you can see the example here

"open": "patch:open@npm:8.4.0#.yarn/patches/open-npm-8.4.0-df63cfe537",

Make sure the patch path is relative from the location of your yarn.lock file

@frantisekhanzlikbl
Copy link
Contributor

Hmm, that requirement is kinda problematic, as I also need to patch dependencies in workspaces, for which yarn uses the ~ prefix. (example from my repo: patch:next@npm%3A13.2.1#~/.yarn/patches/next-npm-13.2.1-585715321e.patch).

Yarn fails to install these, as the .yarn/patches directory doesn't exist in the builder's workdir. I have a half-assed patch for this repo that just links the patch directory to where it needs to be for yarn to find it, but I'd like to solve this properly.

I haven't done much debugging, as admittedly I am still figuring out how this library works, but I'd love to help if I can.

@madjam002
Copy link
Owner Author

Yes the linked example is also a workspace, I think Yarn will create the patch with the ~/ prefix by default, but if you change the referenced patch to just be a relative path then it should work, the ~ prefix is unsupported.

@frantisekhanzlikbl
Copy link
Contributor

Sorry, I meant to write workspace member 😄
After getting rid of the prefix, and fixing the paths to be relative to their respective package.jsons, everything works like a charm. Thanks so much for the help!

Would you accept a PR adding a note about this (and perhaps other stuff I wished I knew without reading the source code) to the readme.md?

@madjam002
Copy link
Owner Author

No problem glad it's working now :)

Yes PRs are greatly appreciated, I don't really have much time at the moment to make improvements to yarnpnp2nix beyond the needs that I have for the internal projects that I'm working on, so PRs are very much welcomed :)

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