I love NixOS because it makes system configuration reusable, reliable and modular. The issue I have is that (nixos-) rebuilds tend to be time intensive, big and small rebuilds alike, they just take inconveniently long. Of course you can deal with this by changing the way you work (you just do something else in the meantime). But it certainly is more convenient to do apt-get install xyz
on ubuntu for example.
Now to make small rebuilds faster is something I am not quite sure how to tackle. I guess would mean making the nix language faster more performant and maybe to cache nix expressions in some way.
But for bigger rebuilds I have a few ideas.
The main idea is, to opt for binary derivations over source derivations as a general strategy (without eliminating source derivations). Of course I have not thought through all the consequences this might have, which is why I am putting it out here as a suggestion.
By this I mean something along the lines of what other distributions do, but in the nixy way: in debian, when you install a library, you pick a certain version of it. And when you run a program, it will search for the library, find the version that is installed and compatible, and load the dependencies of that library and so on. Now I appreciate that nixos does not do that, but that in nixos the dependencies are hardwired to fixed versions. My idea here, is to reduce those versions, or at least their build/download time. So to do the thing that debian does, but in a static way (per client application). Let me try to give an example.
Currently it is the case that:
- application A uses library Y and library Y uses library Z
- application B uses a different derivation of library Y since this one uses library G as a replacement for library Z
In nixos this means that A, B, Y1, Y2, Z and G will be built from source. And equally that they all have to be downloaded from the cache to every machine who uses them. E.g. all of them have build costs and/or bandwidth costs.
My suggestion is now that nix builds A, B, Y1, Z and G. And that Y2 is then derived from Y1 but on the client.
In this way we save the build costs for Y2 and the bandwidth for Y2 and most importantly for me personally the time for either compiling or downloading Y2.
I am perfectly aware that the derived Y2 is not exactly the same as the source-built-Y2. But the derived Y2 would still be pure.
On another note:
There are some applications in nixos (for example rustdesk), that are always rebuilt from source on my machine, instead of being loaded from the cache. I understand that there are license issues here.
But this is terribly inconvenient, and for other distributions there are always convenient ways of installing such packages in binary form.
And remember convenience wins over people! The reason why Amazon is so successful is because it is so convenient. So if we want nixos to grow, then convenience should be the default (without again eliminating the alternative).
Hence here my suggestion is, to make the default way that nixos goes, to not build from source (unless the license issue can somehow be navigated, then of course building from source is preferrable). Instead the default version of the app might be a derivation that downloads a .deb package and makes it nix-compatible.
And to make this more nixy, the community might implement a derivation that generates that very same .deb package from source but does not publish the binary but whose result is simply the checksum of the .deb package. In this way we won’t run into license issues, the binary is downloaded from whereever it can be legally downloaded, and yet we have purity and source->bin checksum verification…
In fact we might do this also for apps that we can build and distribute from source. In this way we could drastically reduce the load on the nix cache and thus make nixos a less cost intensive endeavor…