Hacker News new | ask | show | jobs
by Cedricgc 1434 days ago
Interested in hearing more about CUE+Nix

Considering the tight integration between Nix language v. Nixpkgs v. Nix program I mostly see CUE usable to generate data files but would eventually need to be consumed in a .nix config at some point

2 comments

Theoretically languages other than Nix can be used to generate derivations and from that point forward to the finished build result everything should work the same way.

There is already some experimental setup for Nix to call Nickel for producing derivations using a function call importFromNcl. A more language-agnostic FDI (foreign derivation interface?) would be really exciting.

When writing Nix code it can often feel quite opaque what's going wrong, so writing actual package descriptions in a more constrained language like CUE, at least to me, feels like it might help. Better tooling in Nix and the kind of validation that Nickel proposes also look like good bets. I'm glad there is more than one horse in the race to improve the ecosystem.

I have been wondering for some time what would be required to define a package set just like nixpkgs in CUE (since it's not lazy and not touring complete). I only have very vague thoughts on that, so I would love reading about it from someone who knows more about how nixpkgs works or someone actually trying it.

Yes, derivations are the main primitive to target in an agnostic way

Main challenge is the value of the nixpkgs repo is enormous, and that looks tightly tied to Nix the language and its implicit constructs. I think instead of an FDI one would have to provide a true competitor that is more attractive on multiple dimensions like:

- reworking Nix as more a modular architecture (see Tvix: https://tvl.fyi/blog/rewriting-nix)

- Tackling a package repo and Nixos equivalent with day 1 reproducibility (not just repeatability) like https://reproducible-builds.org/

- Better UX experience on the "entrypoints" of Nix like home-manager and dev-shell flakes - I think CUE has some nicer language features for this and does not require figuring out derivation generation, just referencing the existing nixpkgs set

Thanks, I had not heard of Tvix yet.

What do you mean by day 1 reproducibility instead of repeatability? Isn't tracking and eliminating nondeterminism a gradual process anyways?

I don't see how nixpkgs or NixOS is a faulty basis for that kind of work, since I have not run into any flaws with regards to reproducibility that I thought would be easier to address on a clean slate basis.

You're basically right. I'm not 100% sold on this idea, but I think it's a possibility. Most of what I'm seeing right now is CUE facing outward, e.g., to generate typed things from within nix. This[1] is a good example of that. Given how flexible CUE is, and given how similar nix is to HCL, I think it's possible to have CUE emit nix and provide some basic typing that way.

[1] https://github.com/jmgilman/nix-cue