nix-community / dream2nix

Simplified nix packaging for various programming language ecosystems [maintainer=@DavHau]
https://dream2nix.dev
MIT License
976 stars 122 forks source link

Trouble Using Yarn Lockfile (nodejs-package-lock-v3) #837

Open ebarruel opened 7 months ago

ebarruel commented 7 months ago

I am using a yarn lockfile and keep getting this error: error: [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: '#'

The comment is just the header stating that it's an auto-generated file and on the next line that it's a v1 yarn lockfile. I'm not sure if I'm supposed to somehow tell d2n that I'm using yarn.lock besides including this in my default.nix:

nodejs-package-lock-v3 = {
    packageLockFile = "${config.mkDerivation.src}/yarn.lock";
};

Is there another option I'm not properly setting?

DavHau commented 7 months ago

Yarn lock files are currently not supported. You have to use npm to create a paclage-lock.json file

tobiasBora commented 7 months ago

Hum, out of curiosity, why do this thread claims it is supported? Is it refering to another format, or to a legacy version of dream2nix? https://discourse.nixos.org/t/yarn-plugnplay-and-direnv-packaging/19759/12?u=tobiasbora

Second on dream2nix. I’ve used it extensively to package extremely complex yarn-based monorepos with workspaces and a variety of other off use cases, with close to 100% success rate with nodejs-based packages. The nodejs ecosystem is pretty much solved for dream2nix. It has support for both pure (package-lock.json, yarn.lock) and impure translations and provides many paths to solve various problems, such as package overrides, dependency injections, building without devDependencies (so build from the outside with nix instead), etc.

nixos-discourse commented 7 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixify-yarn-v3-with-flake/38848/2

nixos-discourse commented 7 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixify-yarn-v3-with-flake/38848/3

DavHau commented 7 months ago

Yes, yarn was supported in a previous version of dream2nix but deprecated to reduce maintainership burden. Any reason why you cannot use npm for your use case?

PetarKirov commented 7 months ago

@DavHau At work we have several projects all using Yarn v3 and v4. Some of the reasons behind the choice of yarn (vs npm) were:

vtgen commented 2 months ago

same here fwiw. we are pretty heavily ingrained into yarn; with yarn specific tooling already stable and entrenched.

i think we can generate a package.lock.json temporarily; but after a couple hours of putzing with it i am giving up.