Open Ma27 opened 3 years ago
We should probably fix the tests ^^
We should probably fix the tests ^^
I'd like to get some feedback first: also, I removed some features here, so this needs some more discussion before getting the testsuite running again.
cc @lassulus should I base this off nixpkgs then (re https://github.com/NixOS/nixpkgs/pull/108138)?
Note: @lheckemann and I developed this for a customer project, so please keep in mind that this is currently far from ready and has some downsides/regressions I'll mention below.
However, this approach works surprisingly well, so we decided to file a (draft)-PR against this repository to discuss if this is integratable into the upstream yarn2nix. We are well-aware though that getting this mergable is not an easy task, so we are already "prepared" to maintain those changes in
transloadit/yarn2nix
if needed.Also, when reviewing, please look at the changes except for https://github.com/nix-community/yarn2nix/commit/9694f004660be952511d2206af32dce7a1e96d86 (which basically re-adds the Nix code of
yarn2nix
to the repository). This is needed since theyarn2nix
subtree innixpkgs
actually contains allyarn2nix
sources, but has a dev script to sync that code withnix-community/yarn2nix
, so we decided to develop in a fork of this repository.tl;dr
Usually an expression like this is used when building a
yarn
project with dependencies that have e.g. C bindings:This kind of expression has the downside however that you always need to rebuild the C bindings which slows down CI and dev cycles (if
yarn2nix
is used for development).These changes basically move the build scripts defined in
pkgConfig
into their own derivations and ensure that all required npm dependencies are available as well. Due to that, the time for a recompile is saved.Downsides
In the current state of the branch, the following features are not available:
Right now it's always necessary to generate the
yarn.nix
before runningnix-build
. This is needed since we have to fetch metadata about transitive dependencies from either the registry itself or thepackage.json
of a git repository. That kind of information is needed to make sure that only needed dependencies are available in a derivation to build a NPM package with an extra build script inpkgConfig.*
.I had to change the format of
yarn.nix
a bit, so existing files would break.