Hacker News new | ask | show | jobs
by ratorx 384 days ago
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).

1 comments

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.