Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Changelog: Lazy trees (faster Nix builds) (determinate.systems)
68 points by internet_points 6 months ago | hide | past | favorite | 10 comments


Lazy trees is a long awaited change for many, without it flakes are essentially unusable in monorepos. As a one-time Nix user, Flakes definitely don't seem like an ideal solution but the Nix community lets perfect be the enemy of better too often, and it has the largest following of all the solutions out there (niv being another). Given that, I hope lazy-trees and other improvements that make it actually usable get merged into Nix upstream.

If the NixOS/Nix maintainers don't like flakes/DetSys (which I think is somewhat valid!), they need to put forward a canonical way of pinning channels, otherwise there's not really an alternative standard for the community to build around. The usual answer of just use niv or some other esoteric solution that a subset of hardcore Nix users like isn't enough.


I’m building a (small) monorepo with Niv. It is much easier to understand and use than flakes. Flakes are simpler to use directly for sure (eg from CLI), but if you actually want to use them as dependencies, it becomes way harder to understand.

All Niv does is produce a JSON file with your dependencies, then you use the Nix functions they provide to read and load the dependencies. It is probably the simplest possible dependency management strategy in Nix.

This is also not a Nix specific strategy tbh. If you are using Python, Go, JS, etc they manage dependencies in the same style (lock file with dependencies, tool to update them).

I don’t think the documentation for it is any worse than the rest of Nix (low bar, but we are comparing things in the Nix ecosystem).


I’m curious what you find harder to understand about flakes as dependencies


Flakes seem a lot more magic under the hood, whereas Niv is just providing the arguments to existing Nix functions. They need special handling for nested dependencies (“follows” is a bit weird and hard to discover). With Niv, everything is just a function evaluation. Dependencies source caching is non-obvious for nested dependencies, with Niv it is more explicit (although you do need to manually instantiate them, but I prefer the explicitness).

Nothing major, but it just adds a bit of cognitive load.


The discussion on the PR linked in this post, about upstreaming lazy trees to Nix proper, seems to indicate that some of the benefits also require changing the semantics of the Nix language.

I'm not familiar enough with Nix to understand, but it looks like the performance gains in the blog post might not all materialize to upstream users.

In any case, cool stuff


I feel like Nix' language may be the biggest hurdle for beginners/newcomers.

Interestingly, I recently found out that someone is working on being able to compile Gleam to Nix: https://codeberg.org/glistix/glistix


Nope! This feature is completely agnostic to the Nix language, dealing only with how/when files are copied to the Nix store. More of an under-the-hood implementation detail than anything, although one with important consequences.


I've been awaiting the completion of this branch for years!

I Installed Determinate Nix (via Nix-Darwin— I find it a bit annoying that their official Nix-Darwin module reverts Nix to non-declarative management) on my laptop in order to kick the tires.

May the lazy-trees-v2 branch soon be merged into mainline Nix as well. :)

Congrats to Eelco on getting this work into a state that he's ready to present to users. I hope testing goes well for DetSys users, including me!


If you did flakes with impure does it avoid copying source into the store ?

I'm willing to add impurity especially about the system.

Having to define the systems feels unnecessary. Just define the targets for all systems and let me choose the one I want to build.

Coming across modules that forgot to add a particular system is frustrating.

Any other ways to circumvent this?


https://git.lix.systems/lillecarl/flake-compat/src/branch/ma...

You can output whatever you want in a flake, with impure you can read system with builtins.currentSystem.

flake-compat (my fork and lix fork) supports evaluating from FS. Flake-compat just reads the lockfile and doesn't actually use "flake evaluation mode").




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: