dream2nix
dream2nix copied to clipboard
Node package-lock v2
Putting this in a separate PR from #195 to split up discussions.
I think the test error may be because I'm adding source info for the main package? The reason for that is to be able to pass metadata like hasInstallScripts, and I can only do that via source, right?
My next optimization will be to split the build into
- a pure module unpack with bin symlinks which doesn't call any scripts (thoughts on getting around #214 ?)
- then a built module if
hasInstallScriptsis true, temporarily adding pure-source cycle members to the build - then cyclic packages that combine the previous by copying
This way, if the node version changes, it only rebuilds packages with install scripts.
I noticed that a failed jsonschema validation did not lead to an error in the example tests. This is fixed in 9331fb1376068e24f0ab5080aec85f43a369ebdb.
You can see the schema that the dream-lock is validated against in src/specifications/dream-lock-schema.json.
Instead of adding information to the sources, you can use the subsystmAttrs field to add extra data. This will end up in _subsystem in the final dream-lock and is passed as subsystemAttrs to the builders.
This way, if the node version changes, it only rebuilds packages with install scripts.
Sounds like a nice optimization. But I'd suggest that we first integrate the simplest possible version of the new build logic. Probably as a separate builder. Then test this against many packages. Once we have confidence in it, we can make it the default. That might be valuable even without further optimizations.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/yarn-plugnplay-and-direnv-packaging/19759/26
Support for package-lock v2 and v3 in dream2nix would remove a major hurdle for me in adopting dream2nix. Is there anything that I can help with to get this merged?
I was wondering why dream2nix wouldnt work with my project (lockfile version 3) until I stumbled on this. I am trying this out but nix can't find the git revision. I've been trying to run nix flake update (2.16) but it couldn't find mach-nix, the following fixed this:
- url = "mach-nix";
+ url = "github:DavHau/mach-nix";
then I tried to use my fork https://github.com/teto/dream2nix/tree/node-pkg-v2 on my project, which failed with
at /nix/store/mc6avkywi5473yylvyh64fcl62kdhlgx-source/e2e-candidate/flake.nix:49:6:
48| in
49| (dream2nix.lib.makeFlakeOutputs {
| ^
50| pname = "toto";
error: function 'makeFlakeOutputs' called with unexpected argument 'projects'
@wmertens would you mind rebasing this please ?
@teto I'm kinda burnt out on this, maybe I'll revisit this but right now I have too many other projects. I did notice that nixpkgs now has buildNpmPackage, not sure if that's helpful?