[–] gavinray 16 hours ago
> "Nix is lazy, so the emitted code wraps an expression in nix.thunk(() => ...)"
Why not use Generator functions rather than manually wrapping everything?On-demand value materialization is what Generators are for
[–] boredatoms 1 day ago
[–] isityettime 23 hours ago
Then the things you need to learn in order to read and understand most Nix code is just the stdlib, which is most convenient to browse here: https://noogle.dev/
Beyond that, it's all just conventions that are covered well by reference material. So those two are all you need in order to find your footing when it comes to the Nix language.
(For a tutorial overview of the whole ecosystem, nix.dev is the best entrypoint. For the build system or an introduction to some of the basic "internals", you want The Nix Pills. And in general, the best thing of all to read when it comes to Nix is Nixpkgs itself. :)
[–] john_minsk 1 hour ago
Shortcuts
next page: ctrl + j
prev page: ctrl + k
P.S. thank you for links.[–] YoshiRulz 1 hour ago
[–] tomodachi94 1 day ago
[–] azeirah 23 hours ago
[–] __MatrixMan__ 1 day ago
[–] aitchnyu 21 hours ago
[–] viraptor 20 hours ago
Similar to how JS has x["a"]==x.a, they're attributes.
[–] peter_d_sherman 1 day ago
Heck, not just an excellent article, an exceptional one!
This is why I read HN -- to find articles like this one!
The basic problem:
Everybody loves Software! Software, specifically having a huge breadth and variety for a given platform is the key to that platform's success! (Just ask Bill Gates of Microsoft that, about Windows!) Well a lot of Open Source software is on GitHub, but one problem is (or rather was!) that it needed to get built for a whole bunch of platforms... Simple right? Well, not so much for the average user who is not a programmer when there are numerous types of CPU (x86, ARM, RISC-V, etc., etc.), numerous OS platforms, numerous compilers and compiler versions, and (usually) other dependencies on specific versions of other Open Source software packages...
So who could solve this chaotic "wild west" of exponential build combinations?
Well, historically, GNU autotools (aclocal, autoconf, autoheader, automake, autoreconf, autoscan, gnu m4, libtool, etc., which created files such as: aclocal.m4, config.h, config.h.in, config.log, config.status, configure, Makefile, Makefile.in, etc.) tried to solve this problem, and for the most part did so -- but usually only for users who were familiar with using Unix/Linux command-line tools and usually only for GNU compilers, and build processes which had dependencies on other projects or libraries could break rather spectacularly if the exact correct version of those projects or libraries that the base software was dependent on was not known, or not selected correctly.
What was needed was something more generic, and yet more precise.
Enter Eelco Dolstra, and his Ph.D. thesis "The Purely Functional Software Deployment Model": https://edolstra.github.io/pubs/phd-thesis.pdf
Which is the basis for the Nix functional programming language, NixPkgs and NixOS.
Basically, all problems in software deployment (i.e., configuring and building software correctly from source) could be solved if there was the following:
Immutability in Storage: Once a software component is built, it is stored in a centralized location (the Nix Store, typically /nix/store) and marked as strictly read-only. Components are never modified in place.
Purity of the Build Process: Build actions are treated as mathematical functions. A build process is strictly isolated and hermetic—it is stripped of access to external environment variables or network resources, ensuring that the exact same inputs will always produce the exact same cryptographic output.
Well, turns out Eelco Dolstra and Nix / NixOS were right!
Why? Because now there are over 140,000 Open Source software packages in NixPkgs, i.e., installable by the Nix Package Manager. That's more than any other Linux package collection. And the breadth of combinations of CPU's, Platforms, OS'es, etc., far surpasses the build options of any other Linux distro's package collection!
But that's the next problem, and that's the problem this article so brilliantly addresses -- which is, if all of that software ecosystem, all of those build scripts are ultimately tied to Nix language, and the Nix language is hard to understand / hard to modify for newcomers to it, then how to unbind that entire software ecosystem from the Nix language?
And the answer (or at least one answer!) is what this article author suggests, which is "hey, let's convert the Nix language to Typescript"!
And this is (one great!) solution to the following problem:
>"Anyone who wants to explore the store-model space from a different direction, a new language, a new evaluator, a new editor experience, must then start from zero packages. This is the graveyard where other reimplementations or forks of Nix go to die."
Well not anymore!
Anyway, a truly brilliant article!
[–] tom_alexander 1 day ago
[–] OskarS 15 hours ago
You're correct in that the article is wrong in saying you can't use a nix repl this way, but I took the broader point of it to be "Nix-the-language gets in the way of the Nix-the-model". Which is something that I personally agree with 100% and I think the article illustrates beautifully.
[–] alexandrutocar 18 hours ago
[–] tensegrist 16 hours ago
[–] skavi 21 hours ago
[–] tom_alexander 18 hours ago
What's weird is Farid absolutely knows about both nixd and `nix repl` but he didn't mention either of them or compare, instead making it sound like nix doesn't have a repl or a language server.