Coder Social home page Coder Social logo

Pure nix yarn.lock parsing about js2nix HOT 4 OPEN

canva-public avatar canva-public commented on June 18, 2024
Pure nix yarn.lock parsing

from js2nix.

Comments (4)

bouk avatar bouk commented on June 18, 2024 1

Thinking about it some more, I think the IFD would only appear if you are packaging an external source, that is you're using js2nix on a project fetched from GitHub or somethingโ€”in that case you'd need to vendor the yarn.lock.

from js2nix.

olebedev avatar olebedev commented on June 18, 2024

Hi @bouk, wow, it looks awesome! ๐Ÿ™‚

so it can work without having to generate and commit a yarn.lock.nix file. This would make the user experience a lot nicer since you'd only have to run yarn update to upgrade a version for example, without having to then run js2nix as well

Yeah, this I a really good developer experience I think and the js2nix supports it already. You might notice that there is yarn.lock.nix file in this repository and it must be committed into the repository because it is being used to bootstrap the tool itself - dependencies for the js2nix CLI are provided via the yarn.lock.nix file + js2nix Nix library. Other than that, there is no need to commit generated yarn.lock.nix files for the consumers of this project and the Nix expression can be purely (purity here is a requirement, see project's goals section here) generated on-fly. However, it is possible to manually pre-generate such files, if you want to avoid the Import From Derivation situation for some reason. For more details see the first section here.

The tool was implemented in JS initially for a single reason, to make the PoC asap and iterate over with a reasonable pace. I would love to see it implemented in Nix where possible/reasonable. I am not sure, however, if this is something that can be easily done in Nix language: besides a pure representation of a yarn.lock file the resulting Nix expression addressed the dependencies cycles problem, described here. I wouldn't have time re-implementing cycles hosting it in Nix somewhen in nearest future, but I would be happy to review and merge this changes.

A potentially interesting aspect of having on-fly yarn.lock file representation in Nix could be avoid IFD, but as long as any builtins.readFile operation is considered as IFD it doesn't really make a big difference.

Thanks for sharing your implementation, it's very interesting digging into reading through it!

from js2nix.

bouk avatar bouk commented on June 18, 2024

Yes exactly, it'd like to avoid IFD whenever possible, performance being the main reason! The readFile would cause an IFD if the yarn.lock file was generated as well, so if you're packaging up your own code that should be fine.

I'll look at the cyclic dependency thing, it should be solvable. But I'm glad you're interested, I'll have to see if I can implement a function that generates the equivalent of the whole yarn.lock.nix file.

from js2nix.

olebedev avatar olebedev commented on June 18, 2024

The readFile would cause an IFD if the yarn.lock file was generated as well, so if you're packaging up your own code that should be fine.

Oh, you are right. I read it again and it seems as long as you readFile not from derivation (f drv) it should be fine.

Wow, that actually looks exciting if we can remove IFD from this tool. The IFD is not a blocker for us at the moment but it brings some complexity into pipelines and definitely slows down parallel Nix build execution. Thanks for your suggestion, I look forward to getting the change in ๐Ÿ™‚

from js2nix.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.