Open madjam002 opened 2 years ago
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.
Yes patches are supported, you can see the example here https://github.com/madjam002/yarnpnp2nix/blob/3dfd02b812b003817fb0fa20ebf47a5dc047bbb0/test/workspace/package.json#L10
Make sure the patch path is relative from the location of your yarn.lock file
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.
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.
Sorry, I meant to write workspace member :smile:
After getting rid of the prefix, and fixing the paths to be relative to their respective package.json
s, 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?
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 :)
The package could be fetched in a FOD derivation and then patched in a separate derivation with no outputHash needed.