I think flakes brings us some good things (pure evaluation by default, better evaluation caching, and a much-improved UX for the Nix CLI), and now that Nix 2.4 is out, the question of how to bring those good things to full fruition in stable releases of Nix (without gating them behind an experimental flag) is more relevant than ever.
I’d like to ask whether or not the following resembles what community members and Nix developers themselves have in mind for that process.
I wrote up a long post several months ago, originally for this thread as a step toward a new RFC for flakes, but never posted it because I realized I didn’t really have the determination and skills to see it through or the social capital required to rally important community members behind it. But I think it’s still relevant, and maybe it’s worth putting out there at this point. It’s abridged and adapted below.
The basic idea is if we break flakes into pieces, the motivation for each piece of flakes is a subcommand of the new Nix CLI.
One of the difficulties with the original flakes RFC was its extremely broad scope. Flakes were designed to support the whole range of uses cases covered by the new functionality of the nix
command, as well as new functionality in nixos-rebuild
and nixops
. This makes it a lot harder to answer the question
What are flakes and what are they for?
in a straightforward and concise way. I think if we let the CLI features drive the flakes implementation (as they’ve done in fact anyway), one incremental path forward is obvious.
Proposal: an incremental stabilization/release strategy for Nix flakes
- Stabilize a syntax and CLI usage for lockable Nix resource URIs¹
- Stabilize a syntax for the
inputs
schema - One-by-one, stabilize the portion of the
flake.nix
outputs schema corresponding to the functionality of some flakes-awarenix
subcommand- optionally stabilize the interface of
nix
subcommand which relies on it at the same time - the first flakes-enabled version of Nix needs to include usable equivalents to at least the following:
nix search
nix-env -i
nixos-rebuild
nix-channel
- optionally stabilize the interface of
The suggested minimal subset of functionality above requires the stabilization of the flake.nix
outputs schema only for:
- ‘legacy packages’, i.e., packages that are assumed to be organized and named however Nixpkgs currently happens to organize and name them (for
nix-env -i
andnix search
, and the equivalent ofnix-channel
) - hosts (or what is called a ‘system flake’, e.g., in
flake-utils-plus
) (fornixos-rebuild
(and later,nixops
,nix-darwin
and friends))
Caveats
Obviously all of this can only be a useful suggestion if it’s attractive to the people working on Nix, and especially the people implementing flakes, i.e., Eelco.
But I wanted to put it out there as a way that flakes could move forward piecemeal and democratically, so that the question ‘what is this trying to accomplish?’ is easy to answer at each step.
Questions
Does this kind of release strategy for an official, ‘stable’ implementation of flakes and related tooling seem relevant to this discussion?
Is this kind of incremental release strategy agreeable to Nix and Nixpkgs contributors who are happy to have seen a new Nix release (I am!) and understand the importance of enabling pure evaluation by default, but share the concerns of the signatories in the OP?
Do Nix contributors who are invested in flakes as part of Nix’s future see the incremental release strategy outlined above as helpful to or aligned with their vision for Nix and the way forward, post-2.4?
What concerns related to flakes (other than the long-awaited and then all-at-once release process) are not addressed by an incremental strategy like the one outlined above?
¹: A lockable Nix resource URI is any URI:
- that the Nix CLI tools and Nix language interpreter can understand as a primitive
- whose syntax either
- fully determines the referent of the URI irrespective of context, or
- which, given a context, can be reduced by Nix to a URI which meets the condition above