How to handle conditional / `@patch` dependencies
Hi,
I recently tried to migrate the VS Code extension build of Nickel to use yarn-plugin-nixify. As you can see, the build succeeds for Linux but fails for Darwin OSes.
> patching sources
> updateAutotoolsGnuConfigScriptsPhase
> configuring
> ➤ YN0000: ┌ Resolution step
> ➤ YN0000: └ Completed
> ➤ YN0000: ┌ Fetch step
> ➤ YN0056: │ fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1: Cache entry required but missing for fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1
> ➤ YN0013: │ 375 packages were already cached, one had to be fetched (fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1)
> ➤ YN0000: └ Completed
> ➤ YN0000: Failed with errors in 0s 114ms
By looking into yarn.lock we see the following about fsevents:
"fsevents@npm:~2.3.1":
version: 2.3.2
resolution: "fsevents@npm:2.3.2"
dependencies:
node-gyp: latest
checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f
conditions: os=darwin
languageName: node
linkType: hard
"fsevents@patch:fsevents@~2.3.1#~builtin<compat/fsevents>":
version: 2.3.2
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"
dependencies:
node-gyp: latest
conditions: os=darwin
languageName: node
linkType: hard
Notice the conditions: os=darwin, and the fsevents@patch:fsevents@~2.3.1#~builtin<compat/fsevents> package.
But to my surprise, when we look into the generated yarn-project.nix:
- there is no mention whatsoever of
darwin - only
fsevents@npm:2.3.2is present, the other one is absent!
So I guess I have 3 questions :sweat_smile:
- how are conditional dependencies supposed to be handled by this plugin?
- why isn't
fsevents@patch:fsevents@~2.3.1#~builtin<compat/fsevents>present in the generatedyarn-project.nixfile? - would you have any idea how to fix the original problem, in case the 2 previous questions are not enough to solve this? :pray:
I searched in the documentation, code and issues, but with poor results :disappointed:
The only part that looks interesting is in generate.ts function collectTree:
https://github.com/stephank/yarn-plugin-nixify/blob/main/src/generate.ts#L149
but that does not help me understand what I should do to make this work.
Please let me know if I can provide any additional information to help investigate!
@sir4ur0n you might want to try https://github.com/madjam002/yarnpnp2nix as it seems like it supports conditions
Or you could port the implementation to here
I ran into this problem as well (see the linked issue above), and I don't really know what changed, but it works with Yarn v4 for me!
supportedArchitectures:
os: [linux, darwin, win32]
cpu: [x64, arm64]
See https://github.com/catppuccin/vscode/pull/215, ef47700 failed, but adding supportedArchitectures fixed it for me.