-
Notifications
You must be signed in to change notification settings - Fork 14
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
Some sort of peer dependency automation #24
Comments
Hi @yangm97, Yeah, this is a known issue with the current approach. I agree that it's far from perfect and adds maintainability burden which we better to avoid. As long as the js2nix pretends to be deterministic and reproducible, it acts as a pure function of the What I can think of is we can try to fetch the whole closure while develop the closure for a project and let js2nix to download the whole closure and infer correct dependency tree. This is essentially what node2nix does and there are quite a lot of complainants about this behavior. TL;DR: it takes ages to re-download stuff on every Node.js closure change. Also, this approach is not reproducible as long as we infer sha sums out of the real artifacts but not rely on what Another idea to explore is to split the package build into two phases: 1) fetch and unpack, 2) read the The situation you report is basically exactly the same for PNPM. They suggest a couple of valuable approaches here (the option 3 is similar to what we do with Note, the Happy to discuss it further to infer the best solution that doesn't contradict to the idea of js2nix to be pure and reproducible. If the IFD approach (which we already have by default in js2nix) is a necessary evil I think we can try to make the second idea work at some extent. |
I wonder if it would be possible to pay the IFD cost during the The idea would be to download + extract then resolve While this is indeed a hack, it seems like way too many babel, react, react native etc. packages intentionally make use of this feature as to avoid duplicate versions of what would be a "global dependency", as metro probably wouldn't like to bundle multiple react versions for a given app. It also kind of works as a way to signal which library versions are compatible with a given react version. On a side note, I noticed there's a circular dependency cycle going on with babel/core and babel/whatever-transforms, so if I try to override babel/core into this dependency I get an infinite recursion error from the nix side. The usage guide seems to describe that in these situations packages would be bundled into the same derivation so if that is a bug let me know what I can do to help diagnose this. |
Ah, I see, we can introduce a flag to the js2nix CLI, like
Nope, this is not a bug. The cycles are resolved before the final Nix expression generation while the overrides ( How do you feel with make a PR that does the trick? |
Have a look at the dependency cycles resolution section (I am sure you've done that already, but) you can see that you can manually implement hosted packages as well, using the |
Funny thing is the one time I consciously get over the immediate itch to automate something as to not fall into relevant xkcd, it turns out that actually, that would have been the saner option, instead of making this abomination (which doesn't even work so yeah...) I'm reading the code and it looks like I should run a |
Oh, yes, this doesn't look neat, 100%. Yeah, I guess, you would need to modify this section here in the way it asynchronously fetch When I was working on this part, I initially made it in Please make sure you put this behavior behind an option so the change doesn't affect the current behavior silently. I guess we can also utilize Nix for this task to make sure we cached the "fetch-and-parse-package-json" action in Nix store, so we address the main concern associated with node2nix - re-download the whole closure on any change. |
I'm trying to adopt js2nix in a react-native app but having to manually resolve each peer dependency in this environment has been... painful.
I very much like the fact js2nix is not opinionated and so guarantees package lookup reproducibility but I wish there was some way to automate the
addDependency
dance.The text was updated successfully, but these errors were encountered: